You are here: Re: Best Practice - Constant Page Layouts « PHP Programming Language « IT news, forums, messages
Re: Best Practice - Constant Page Layouts

Posted by Justin Voelker on 04/03/07 17:31

On Apr 3, 12:31 pm, "klenwell" <klenw...@gmail.com> wrote:
> 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.com> 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!

Thank you very much Tom! I'll have to give this one a shot.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация