John W. Holmes said: > From: "Chris de Vidal" <[EMAIL PROTECTED]> >> Kelly Hallman said: >> > Going even one step further (the beauty of Smarty: always another > level), >> > just extend the Smarty object itself. Then, instead of making all your >> > templates includes other templates (such as a header or a footer), you > can >> > make your overall page be a template, and the extended Smarty object >> can >> > be given extra functionality to control the page: >> > >> > {* MyPage.tpl -- Smarty template for the entire page *} >> > ...header... >> > {include file=$content} >> > ...footer... >> > >> > // mypage.php -- extended Smarty object >> > class MyPage extends Smarty { >> > var $tmpl = 'MyPage.tpl'; >> > function render($x) { >> > $this->assign('content',$x); >> > $this->display($this->tmpl); } } >> > >> > // actualphpcode.php -- called by the browser >> > $pt = new MyPage; >> > $pt->render('pagecontent.tpl'); >> >> Sorry, I'm feeling better now but still don't understand what you're >> telling me/us. Could you please expound? What functionality does this >> afford? > > If I can take first shot, since this was posted to the list... :)
No!!! Well, OK. :) > It's basically a wrapper around Smarty to automatically load the > header-content-footer template and dynamically fill in the content based > on what's passed to render. So, displaying all of your different pages > would be as simple as: > > $pt = new MyPage; > $pt->render('contact.tpl'); > > $pt ->render('prices.tpl'); > > $pt->render('index.tpl'); > > etc... The "wrapper" automatically loads the "master" template with the > header and footer, and then replaces the {content} tag with the content of > the appropriate template that render() was passed. > > Just one method of many. If I'm interpreting it right, that is. :) Ahh OK, that makes sense, 'cept now you've introduced new confusion (sorry, I must be dense today). What's with loading all of your pages (contact/prices/index) in one page? Or are you saying: $pt = new MyPage; $pt->render('contact.tpl'); OR $pt = new MyPage; $pt ->render('prices.tpl'); OR $pt = new MyPage; $pt->render('index.tpl'); I can see the benefit of this method if that's what you mean. Thanks for helping clarify it, /dev/idal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php