470,820 Members | 1,643 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,820 developers. It's quick & easy.

Best Practice - Constant Page Layouts

Hello Everyone:

I am in search of an easier way to develop pages. My most current
website, www.Base2WebDesign.com, has the exact same layout throughout
the entire site. Right now I use a function called "page_top()" and
page_bottom()" that , when called, display the tops and bottoms of
pages. All I have to do on the actual index.php page is call those two
functions and then write the main content on that page. This seems
stupid but it seems to work. I would like to use templates but I
don't know much about them and I have yet to find anything that just
screams simplicity to me and ease of use. If anyone could point me in
the right direct for developing pages that have a consistent layout
with dynamic content on the "main section" of the page, I would be
forever grateful. Again, I would like to use templates because from
what I have seen they look like they are what I need. Can anyone
direct me toward and very simple, straight-forward, easy-to-use
template system (if this is what I indeed would need) that could speed
up the rendering of the pages without hitting the server on each page
load for the same page layout? Also, my current way of building the
page may be to fault but might there be a solution to the pages
"blinking" when you switch from one pages to the next for the first
time. When you return to that same page there is no blink. Thank you
so much to anyone and everyone that can solve any of the problems I
have listed above!

Apr 2 '07 #1
13 1676
In article <11**********************@l77g2000hsb.googlegroups .com>,
ju************@gmail.com says...
Hello Everyone:

I am in search of an easier way to develop pages. My most current
website, www.Base2WebDesign.com, has the exact same layout throughout
the entire site. Right now I use a function called "page_top()" and
page_bottom()" that , when called, display the tops and bottoms of
pages. All I have to do on the actual index.php page is call those two
functions and then write the main content on that page. This seems
stupid but it seems to work. I would like to use templates but I
don't know much about them and I have yet to find anything that just
screams simplicity to me and ease of use. If anyone could point me in
the right direct for developing pages that have a consistent layout
with dynamic content on the "main section" of the page, I would be
forever grateful. Again, I would like to use templates because from
what I have seen they look like they are what I need. Can anyone
direct me toward and very simple, straight-forward, easy-to-use
template system (if this is what I indeed would need) that could speed
up the rendering of the pages without hitting the server on each page
load for the same page layout? Also, my current way of building the
page may be to fault but might there be a solution to the pages
"blinking" when you switch from one pages to the next for the first
time. When you return to that same page there is no blink. Thank you
so much to anyone and everyone that can solve any of the problems I
have listed above!

I think its probably fair to say you are already doing it.
There was also once a concept of "frames" which would address your
reloading blink question - but they seem to have gone out of fashion -

I don't know why - perhaps someone could enlighten me (us) on why just
for curiosity?

Andy
Apr 2 '07 #2
Justin.Voelker wrote:
Hello Everyone:

I am in search of an easier way to develop pages. My most current
website, www.Base2WebDesign.com, has the exact same layout throughout
the entire site. Right now I use a function called "page_top()" and
page_bottom()" that , when called, display the tops and bottoms of
pages. All I have to do on the actual index.php page is call those two
functions and then write the main content on that page. This seems
stupid but it seems to work. I would like to use templates but I
don't know much about them and I have yet to find anything that just
screams simplicity to me and ease of use. If anyone could point me in
the right direct for developing pages that have a consistent layout
with dynamic content on the "main section" of the page, I would be
forever grateful. Again, I would like to use templates because from
what I have seen they look like they are what I need. Can anyone
direct me toward and very simple, straight-forward, easy-to-use
template system (if this is what I indeed would need) that could speed
up the rendering of the pages without hitting the server on each page
load for the same page layout? Also, my current way of building the
page may be to fault but might there be a solution to the pages
"blinking" when you switch from one pages to the next for the first
time. When you return to that same page there is no blink. Thank you
so much to anyone and everyone that can solve any of the problems I
have listed above!
Even a template will have to hit the server for every page load, even if
it is the same layout. The only way you could stop that is to save the
page outputs as html files and just load the static pages.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 2 '07 #3
On Apr 2, 12:13 pm, and...@blueyonder.com wrote:
In article <1175529378.263026.220...@l77g2000hsb.googlegroups .com>,
justin.voel...@gmail.com says...
Hello Everyone:
I am in search of an easier way to develop pages. My most current
website,www.Base2WebDesign.com, has the exact same layout throughout
the entire site. Right now I use a function called "page_top()" and
page_bottom()" that , when called, display the tops and bottoms of
pages. All I have to do on the actual index.php page is call those two
functions and then write the main content on that page. This seems
stupid but it seems to work. I would like to use templates but I
don't know much about them and I have yet to find anything that just
screams simplicity to me and ease of use. If anyone could point me in
the right direct for developing pages that have a consistent layout
with dynamic content on the "main section" of the page, I would be
forever grateful. Again, I would like to use templates because from
what I have seen they look like they are what I need. Can anyone
direct me toward and very simple, straight-forward, easy-to-use
template system (if this is what I indeed would need) that could speed
up the rendering of the pages without hitting the server on each page
load for the same page layout? Also, my current way of building the
page may be to fault but might there be a solution to the pages
"blinking" when you switch from one pages to the next for the first
time. When you return to that same page there is no blink. Thank you
so much to anyone and everyone that can solve any of the problems I
have listed above!

I think its probably fair to say you are already doing it.
There was also once a concept of "frames" which would address your
reloading blink question - but they seem to have gone out of fashion -

I don't know why - perhaps someone could enlighten me (us) on why just
for curiosity?

Andy
Andy:

I once used frames and you are right, they seem to have been killed
off. I just didn't know if a template system would achieve the same
sort of results without being so terribly coded as they are right
now. Thanks for the response though!

Apr 2 '07 #4
On Apr 2, 1:17 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Justin.Voelker wrote:
Hello Everyone:
I am in search of an easier way to develop pages. My most current
website,www.Base2WebDesign.com, has the exact same layout throughout
the entire site. Right now I use a function called "page_top()" and
page_bottom()" that , when called, display the tops and bottoms of
pages. All I have to do on the actual index.php page is call those two
functions and then write the main content on that page. This seems
stupid but it seems to work. I would like to use templates but I
don't know much about them and I have yet to find anything that just
screams simplicity to me and ease of use. If anyone could point me in
the right direct for developing pages that have a consistent layout
with dynamic content on the "main section" of the page, I would be
forever grateful. Again, I would like to use templates because from
what I have seen they look like they are what I need. Can anyone
direct me toward and very simple, straight-forward, easy-to-use
template system (if this is what I indeed would need) that could speed
up the rendering of the pages without hitting the server on each page
load for the same page layout? Also, my current way of building the
page may be to fault but might there be a solution to the pages
"blinking" when you switch from one pages to the next for the first
time. When you return to that same page there is no blink. Thank you
so much to anyone and everyone that can solve any of the problems I
have listed above!

Even a template will have to hit the server for every page load, even if
it is the same layout. The only way you could stop that is to save the
page outputs as html files and just load the static pages.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
Jerry:

Do you know of any nice, simple, light-weight php template systems
(unline smarty and it's massive amount of files). Thanks!

Apr 2 '07 #5
Justin.Voelker wrote:
On Apr 2, 1:17 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>Justin.Voelker wrote:
>>Hello Everyone:
I am in search of an easier way to develop pages. My most current
website,www.Base2WebDesign.com, has the exact same layout throughout
the entire site. Right now I use a function called "page_top()" and
page_bottom()" that , when called, display the tops and bottoms of
pages. All I have to do on the actual index.php page is call those two
functions and then write the main content on that page. This seems
stupid but it seems to work. I would like to use templates but I
don't know much about them and I have yet to find anything that just
screams simplicity to me and ease of use. If anyone could point me in
the right direct for developing pages that have a consistent layout
with dynamic content on the "main section" of the page, I would be
forever grateful. Again, I would like to use templates because from
what I have seen they look like they are what I need. Can anyone
direct me toward and very simple, straight-forward, easy-to-use
template system (if this is what I indeed would need) that could speed
up the rendering of the pages without hitting the server on each page
load for the same page layout? Also, my current way of building the
page may be to fault but might there be a solution to the pages
"blinking" when you switch from one pages to the next for the first
time. When you return to that same page there is no blink. Thank you
so much to anyone and everyone that can solve any of the problems I
have listed above!
Even a template will have to hit the server for every page load, even if
it is the same layout. The only way you could stop that is to save the
page outputs as html files and just load the static pages.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================

Jerry:

Do you know of any nice, simple, light-weight php template systems
(unline smarty and it's massive amount of files). Thanks!
Sorry, I don't use templates.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 2 '07 #6
There isn't a whole lot out there besides smarty, and you've already
said you don't like it (although it does have built-in caching to
speed up rendering, if you want it). I personally don't like smarty
because it just feels like an unnecessary scripting language on top of
another scripting language.

I still wanted to be able to separate business logic from display
logic, though, so came up with my own homebrew quasi-templating
system. I based in around the CSS Grids component of the Yahoo YUI
library (http://developer.yahoo.com/yui/grids/). It's basically just
a collection of a few classes that wrap around the css components of
that library, so I can just create a page, add blocks/grids/units,
give them whatever data they need, then just call Render() and it
takes care of structuring the html. The end result being absolutely
no html or display logic in the main file as it's delegated out to the
individual page elements. Crude, yes, but it gives me both the level
of flexibility and abstraction that I like.

Point being, that if Smarty isn't doing it for you, you may want to
think about what exactly you want from a templating system and then
just go do it yourself. The nice thing about your own templating
system is that once you have it, you'll get a lot of miles out of it
because you'll be able to reuse it for just about anything else you do.

Apr 2 '07 #7
an****@blueyonder.com wrote:
In article <11**********************@l77g2000hsb.googlegroups .com>,
ju************@gmail.com says...
>Hello Everyone:

I am in search of an easier way to develop pages. My most current
website, www.Base2WebDesign.com, has the exact same layout throughout
the entire site. Right now I use a function called "page_top()" and
page_bottom()" that , when called, display the tops and bottoms of
pages. All I have to do on the actual index.php page is call those two
functions and then write the main content on that page. This seems
stupid but it seems to work. I would like to use templates but I
don't know much about them and I have yet to find anything that just
screams simplicity to me and ease of use. If anyone could point me in
the right direct for developing pages that have a consistent layout
with dynamic content on the "main section" of the page, I would be
forever grateful. Again, I would like to use templates because from
what I have seen they look like they are what I need. Can anyone
direct me toward and very simple, straight-forward, easy-to-use
template system (if this is what I indeed would need) that could speed
up the rendering of the pages without hitting the server on each page
load for the same page layout? Also, my current way of building the
page may be to fault but might there be a solution to the pages
"blinking" when you switch from one pages to the next for the first
time. When you return to that same page there is no blink. Thank you
so much to anyone and everyone that can solve any of the problems I
have listed above!


I think its probably fair to say you are already doing it.
There was also once a concept of "frames" which would address your
reloading blink question - but they seem to have gone out of fashion -

I don't know why - perhaps someone could enlighten me (us) on why just
for curiosity?

Andy
At least one reason I know of is the problems search engines (were said
to) have (had?) with indexing framed pages. Another one has to do with
frames being reopened in new tabs/windows messing up the site's layout.

Personally I still don't mind using the occasional iframe here and there
where the alternatives imply a LOT of extra work. Shoot me, I've always
been a lazy programmer. A trait I've been more often praised for in this
line of work than not.

Anyone else the definitive answer to andy's question?
Sh.
Apr 3 '07 #8
Justin.Voelker wrote:
Hello Everyone:

I am in search of an easier way to develop pages. My most current
website, www.Base2WebDesign.com, has the exact same layout throughout
the entire site. Right now I use a function called "page_top()" and
page_bottom()" that , when called, display the tops and bottoms of
pages. All I have to do on the actual index.php page is call those two
functions and then write the main content on that page. This seems
stupid but it seems to work. I would like to use templates but I
don't know much about them and I have yet to find anything that just
screams simplicity to me and ease of use. If anyone could point me in
the right direct for developing pages that have a consistent layout
with dynamic content on the "main section" of the page, I would be
forever grateful. Again, I would like to use templates because from
what I have seen they look like they are what I need. Can anyone
direct me toward and very simple, straight-forward, easy-to-use
template system (if this is what I indeed would need) that could speed
up the rendering of the pages without hitting the server on each page
load for the same page layout? Also, my current way of building the
page may be to fault but might there be a solution to the pages
"blinking" when you switch from one pages to the next for the first
time. When you return to that same page there is no blink. Thank you
so much to anyone and everyone that can solve any of the problems I
have listed above!
What will templates give you that you cannot do simpler with PHP ?

I have CubeCart in my store and they implemented some weird macro
language in their templates. Why not PHP files ?

Just compare the snippet:

<!-- BEGIN: cat_img -->
<img src="{IMG_CURENT_CATEGORY}" alt="{TXT_CURENT_CATEGORY}"
border="0" title="{TXT_CURENT_CATEGORY}" />
<!-- END: cat_img -->

With PHP representation

if(cat_img)
{
echo "<img src='$ImgCurrentCategory' alt='$TxtCurrentCategory'
border='0' title='$TxtCurrentCategory' />";
}

Roman

--
www.dipmicro.com - My Electronic Component and Project Store
www.findspec.com - My Electronic Component Datasheet Search Engine
Apr 3 '07 #9
On Apr 2, 8:28 pm, Schraalhans Keukenmeester <bitbuc...@invalid.spam>
wrote:
and...@blueyonder.com wrote:
I don't know why - perhaps someone could enlighten me (us) on why just
for curiosity?
Andy

Anyone else the definitive answer to andy's question?
Sh.
I always thought that frames were a no-no because they broke url
navigation. For example, the user could be a few clicks deep in a
frameset, but the url stills says www.xyz.com. When they make a
bookmark expecting it to take them to that deeper level, it just takes
them back to the main page.

Of course, AJAX now causes essentially the same problem, but
apparently it's a lot cooler than frames were, so it can get away with
it?

Apr 3 '07 #10
I developed a simple single-file template system that uses buffering,
conditionals, and heredocs. Not sure if it's best practice, but it's
worked well for me. It keeps the logic layer and view layer apart,
provides consistency, and yet is quite flexible. The basic outline:

// php section
// html section (escape php) <-- this would be your main output
section
// php section

A skeleton demo:

<?php
// start session, buffering, call files, etc.

// declare variables
$_HTML['navbar'] = '';
$_HTML['section1'] = '';
$_HTML['section2'] = '';

// build output (can call functions, other php files here)
$_HTML['navbar'] = php_build_navbar();

if ( !empty($_HTML['navbar']) )
{
$_HTML['section1'] = <<<HTML
<div id="section1">
{$_HTML['navbar']}
</div>
HTML;
}

$_HTML['section2'] = <<<HTML
<div id="section2" class="static_content">
Some static content
</div>
HTML;

// start html (don't forget doctype and head stuff)
?>
<html>
<head>
</head>
<body>
<?php echo $_HTML['section1']; ?>
<?php echo $_HTML['section2']; ?>
</body>
</html>

<?php
// dump buffer
?>

For more efficiency, combine with PEAR's cache_lite package or another
caching class.

You could continue to automate things and tailor a system that works
for you. Take it far enough and you'll end up with something like
Smarty or another pre-existing template system.

Tom

On Apr 2, 8:56 am, "Justin.Voelker" <justin.voel...@gmail.comwrote:
Hello Everyone:

I am in search of an easier way to develop pages. My most current
website,www.Base2WebDesign.com, has the exact same layout throughout
the entire site. Right now I use a function called "page_top()" and
page_bottom()" that , when called, display the tops and bottoms of
pages. All I have to do on the actual index.php page is call those two
functions and then write the main content on that page. This seems
stupid but it seems to work. I would like to use templates but I
don't know much about them and I have yet to find anything that just
screams simplicity to me and ease of use. If anyone could point me in
the right direct for developing pages that have a consistent layout
with dynamic content on the "main section" of the page, I would be
forever grateful. Again, I would like to use templates because from
what I have seen they look like they are what I need. Can anyone
direct me toward and very simple, straight-forward, easy-to-use
template system (if this is what I indeed would need) that could speed
up the rendering of the pages without hitting the server on each page
load for the same page layout? Also, my current way of building the
page may be to fault but might there be a solution to the pages
"blinking" when you switch from one pages to the next for the first
time. When you return to that same page there is no blink. Thank you
so much to anyone and everyone that can solve any of the problems I
have listed above!

Apr 3 '07 #11
On Apr 3, 12:31 pm, "klenwell" <klenw...@gmail.comwrote:
I developed a simple single-file template system that uses buffering,
conditionals, and heredocs. Not sure if it's best practice, but it's
worked well for me. It keeps the logic layer and view layer apart,
provides consistency, and yet is quite flexible. The basic outline:

// php section
// html section (escape php) <-- this would be your main output
section
// php section

A skeleton demo:

<?php
// start session, buffering, call files, etc.

// declare variables
$_HTML['navbar'] = '';
$_HTML['section1'] = '';
$_HTML['section2'] = '';

// build output (can call functions, other php files here)
$_HTML['navbar'] = php_build_navbar();

if ( !empty($_HTML['navbar']) )
{
$_HTML['section1'] = <<<HTML
<div id="section1">
{$_HTML['navbar']}
</div>
HTML;

}

$_HTML['section2'] = <<<HTML
<div id="section2" class="static_content">
Some static content
</div>
HTML;

// start html (don't forget doctype and head stuff)
?>
<html>
<head>
</head>
<body>
<?php echo $_HTML['section1']; ?>
<?php echo $_HTML['section2']; ?>
</body>
</html>

<?php
// dump buffer
?>

For more efficiency, combine with PEAR's cache_lite package or another
caching class.

You could continue to automate things and tailor a system that works
for you. Take it far enough and you'll end up with something like
Smarty or another pre-existing template system.

Tom

On Apr 2, 8:56 am, "Justin.Voelker" <justin.voel...@gmail.comwrote:
Hello Everyone:
I am in search of an easier way to develop pages. My most current
website,www.Base2WebDesign.com, has the exact same layout throughout
the entire site. Right now I use a function called "page_top()" and
page_bottom()" that , when called, display the tops and bottoms of
pages. All I have to do on the actual index.php page is call those two
functions and then write the main content on that page. This seems
stupid but it seems to work. I would like to use templates but I
don't know much about them and I have yet to find anything that just
screams simplicity to me and ease of use. If anyone could point me in
the right direct for developing pages that have a consistent layout
with dynamic content on the "main section" of the page, I would be
forever grateful. Again, I would like to use templates because from
what I have seen they look like they are what I need. Can anyone
direct me toward and very simple, straight-forward, easy-to-use
template system (if this is what I indeed would need) that could speed
up the rendering of the pages without hitting the server on each page
load for the same page layout? Also, my current way of building the
page may be to fault but might there be a solution to the pages
"blinking" when you switch from one pages to the next for the first
time. When you return to that same page there is no blink. Thank you
so much to anyone and everyone that can solve any of the problems I
have listed above!
Thank you very much Tom! I'll have to give this one a shot.

Apr 3 '07 #12
I've uploaded a more complete working example here:

http://klenwell.googlecode.com/svn/t...rame.blank.php

Same basic concept but with a more explicit controller mechanism --
useful if you wanted to use this as a site-wide template for multiple
pages. (Also includes a script timer that outputs to an html comment
at the end.) This is the basis of the framework I use, where much of
the initialization gets handed off to included files.

Tom
Apr 3 '07 #13
Moot wrote:
On Apr 2, 8:28 pm, Schraalhans Keukenmeester <bitbuc...@invalid.spam>
wrote:
>and...@blueyonder.com wrote:
>>I don't know why - perhaps someone could enlighten me (us) on why just
for curiosity?
Andy
Anyone else the definitive answer to andy's question?
Sh.

I always thought that frames were a no-no because they broke url
navigation. For example, the user could be a few clicks deep in a
frameset, but the url stills says www.xyz.com. When they make a
bookmark expecting it to take them to that deeper level, it just takes
them back to the main page.

Of course, AJAX now causes essentially the same problem, but
apparently it's a lot cooler than frames were, so it can get away with
it?
You're (also) very right! Bookmarking is a pain w/ frames. And your
guess on AJAX being a hype and therefore getting away with its downsides
may be quite close to the mark as well...
Apr 3 '07 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Peter A. Schott | last post: by
24 posts views Thread by delerious | last post: by
7 posts views Thread by Hostile17 | last post: by
145 posts views Thread by Mark Johnson | last post: by
16 posts views Thread by Jonas Smithson | last post: by
4 posts views Thread by Will Hartung | last post: by
136 posts views Thread by Matt Kruse | last post: by
2 posts views Thread by Ethan V | last post: by
4 posts views Thread by Ned Balzer | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.