473,799 Members | 3,121 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
13 1823
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_navba r();

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

$_HTML['section2'] = <<<HTML
<div id="section2" class="static_c ontent">
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_navba r();

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

}

$_HTML['section2'] = <<<HTML
<div id="section2" class="static_c ontent">
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...@inva lid.spam>
wrote:
>and...@blueyon der.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
2478
by: Peter A. Schott | last post by:
I've got a file that seems to come across more like a dictionary from what I can tell. Something like the following format: ###,1,val_1,2,val_2,3,val_3,5,val_5,10,val_10 ###,1,val_1,2,val_2,3,val_3,5,val_5,11,val_11,25,val_25,967,val_967 In other words, different layouts (defined mostly by what is in val_1, val_2, val_3). The ,#, fields indicate what "field" from our mainframe the corresponding value
24
5280
by: delerious | last post by:
Hi, I am designing a web site that will that showcase a bunch of vacation pictures. It will have a banner and a navigation menu (consisting of 13 rectangular images that can be clicked). I am considering a few different layouts: - Banner on top, with the navigation menu immediately below it. The problem with this layout is that the menu would be about 770 pixels wide, since there are 13 items in it. Many users would have to...
7
1892
by: Hostile17 | last post by:
I'm trying to arrive at a kind of "industry standard" or "best practice" approach to CSS for a policy document aimed at developers, but not necessarily very experienced developers. What does the CIWAS community think is the best way to go about styling documents for maximum compatibility/minimum problems with old browsers. We have a range of people currently using a range of techniques, i.e.
145
8862
by: Mark Johnson | last post by:
Oddly enough, I found it difficult, using Google, to find a list of best-of sites based on the quality of their css packages. So I'd ask. Does anyone know of particularly good sites which are in good measure because of their creative and useful css designs? I'm aware of Zen Garden and a few others. So don't bother with those. And I hope I don't get replies from people with a 'tin ear' and no design sense. Good sites. Good pages. That's...
16
2235
by: Jonas Smithson | last post by:
I'm going to say something now that may seem to completely contradict a previous post of mine, in which I basically said that taking a "who cares" attitude about certain browsers (because of their non-standard CSS rendering) makes no sense. Well, you have to draw the line *somewhere*... and contradictory or not, I've decided that I've suffered with Netscape 4 for long enough. Coding workarounds for its brain-dead CSS rendering has...
4
2315
by: Will Hartung | last post by:
The designers have handed me a page that has 5 different blocks on it in the center column (in a typical 3 column layout with page spanning headers and footers). The blocks have elaborate headers (large images), and small content areas that will hold little blocks of text. Currently, I have this done with pixel specific tables within tables within tables, using the images as backgrounds of the repseective TD's.
136
9460
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
2
1320
by: Ethan V | last post by:
I have about 50 string constants that I put all of them in one file. I find that it's too un-organized because I have to intellisense thru lots of unrelated constant to get to the one I want. Is there a best practice for organizing constant? Please share with me your thoughts and experiences. Thanks so much in advance.
4
1842
by: Ned Balzer | last post by:
Hi all, I am pretty new to asp.net; I've done lots of classic asp, but am just beginning to get my mind wrapped around .net. What I'd like to do is include some code that tests if a user is logged in, on each and every page, and redirects the user to a login page if s/he's not logged in. The login page will also take care of some standard setup, such as choosing/populating a user profile. I used to use <!-- #include ... --for this,...
0
10482
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10225
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.