Static Pages

From: Date: Wed, 26 Feb 2003 10:11:44 +0000
Subject: Static Pages
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-8212@lists.php.net to get a copy of this message
Just wondering... how do you guys cope with static pages (i.e. pages that do not strictly require dynamic content)? For example... I'm going with the "one general page template" approach discussed in an earlier thread, as opposed to the "top and bottom" approach. My general page template is something like this: - <html> <body> {include file="$top"} blah blah {include file="$content"} blah blah {include file="$bottom"} </body </html> My general php script for these dynamic pages goes something like this: - <?php // grab stuff from db ... // assign vars to smarty ... ... $smarty->assign('top','news_nav.tpl'); $smarty->assign('content','news_content.tpl'); $smarty->assign('bottom','news_footer.tpl'); // output $smarty->display('general_page.tpl'); ?> This gives quite a lot of freedom, but on the downside, it means that the php coder decides which templates are used for each script in the site. Now, say I want the template/website designer to be able to add some additional static pages to the site. My initial thoughts about accomplishing this are as follows: - 1) The designer creates his custom templates for his new page, to fit into the 'general_page.tpl' template. E.g. 'aboutus_top.tpl', 'aboutus_content.tpl', 'aboutus_footer.tpl'. 2) The coder creates a "static.php" page like this: - <?php // STATIC.PHP // grab incoming get-vars into php variables (input validation omitted here ;-) $top = $_GET['top']; $content = $_GET['content']; $bottom = $_GET['bottom']; // assign vars to smarty $smarty->assign('sid',$SID); $smarty->assign('top',$top); $smarty->assign('content',$content); $smarty->assign('bottom',$bottom); // output $smarty->display('general_page.tpl'); ?> 3) The designer links to his new static page like so: - static.php?{$sid}&top=aboutus_top.tpl&content=aboutus_content.tpl&bottom=abo utus_footer.tpl The {$sid} is the session ID (propogated by url) to keep the session alive between static pages. Now, my questions... does this seem too excessive? Does anyone do something better to accomplish the same results? Can anyone see any flaws to this approach or how to solve them? Thanks for your comments, James

« previous php.smarty.general (#8212) next »