619Chapter 33Stylecode and graphics. If your site has a large number of pages or is very content-rich, you mayfind (as we have) that it s helpful to choose a particular kind of file organization or template, and stick to it across the site. One simplified example follows, which is similar to templateswe have used on www.mysteryguide.comand www.sciencebookguide.com. /* load general functions */ include( general-functions.inc ); /* load functions specific to this page */ include( renaissance-functions.inc ); /* page-wide variables */ $PageTitle = Painters of the Renaissance ; $db_connection = make_database_connection(); ?>
In this example, every page loads the same file of site-wide utility functions, then loads a fileof functions specific to that page, then defines variables that will be global for the page, andfinally intersperses PHP commands in some boilerplate HTML. The content is in columns, andthe actual content displayed depends on the particular page s functions, which always havethe same names, but with definitions varying for each page. Changing what s displayed in thecolumns means either changing the per-page functions or (more likely) modifying thedatabase contents. It would be possible for a nonprogrammer to do some limited design onthis page by operating directly on the HTML and being careful to leave the PHP alone. The preceding example is just one simplified possibility from a range of ways to divide up thelabor of displaying a PHP page. Another that we like even better is the heredoc technique thatwe discuss in the section, The heredoc style, earlier in the chapter. Your particular strategywill depend on the type of site, the size of the site, and the styles of the people contributing. Finally, note that all these strategies really just adopt a convention about separating logic anddisplay in PHP. If you need an even stronger distinction, there are PHP-based templating sys- tems available that further insulate the display people from the innards of program logic. Oneexample is YATS (Yet Another Template System), available at http://yats.sourceforge.net.
We recommend cheap and reliable webhost to host and run your web applications:
Coldfusion Web Hosting services.
This entry was posted
on Sunday, September 16th, 2007 at 5:21 am and is filed under Domain.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.