Re: [SMARTY] Re: include_php options / best practices

From: Date: Fri, 11 Jun 2004 00:12:36 +0000
Subject: Re: [SMARTY] Re: include_php options / best practices
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11443@lists.php.net to get a copy of this message
Justin Patrin wrote: > > I would suggest splitting your templates differently. Put the stuff > above your "dynamic" template include in a header.tpl and the stuff > below it in footer.tpl. Then, include header.tpl and footer.tpl in the > other templates. Your PHP which does the $t->display() call should be > the one choosing which template to use. The PHP that calls that should > also assign the correct vars as necessary. > > So something like this: > > if($content1) { > $t->display('content1.tpl'); > } else { > $t->display('defaultContent.tpl'); > } > > header.tpl: > This is the header > > footer.tpl: > This is the footer > > content1.tpl: > {include file="header.tpl"} > Content 1 > {include file="footer.tpl"} > > defaultContent.tpl: > {include file="header.tpl"} > Default Content > {include file="footer.tpl"} > > If you don't like that solution, I would suggest that you still assign > the vars for each page in the code that calls $t->display() (using a > switch or if), then assign a special var which tells index.tpl which > content template to include, then call $t->display('index.tpl'). > > index.tpl: > header stuff > {include file=$contentTemplate} > footer stuff Yup -- I think that last solution is the the clear-headed solution I was looking for. I was trying to get around including header.tpl and footer.tpl in each template file (trying to be economical and I have some breadcrumb-y stuff going on that I'd have to redo), so I'll try your latter solution. If it doesn't work, I'll do the first thing, which is definitely straightforward (which has been known to trump clever). Out of curiousity, why is include_php being deprecated? Thanks, s. > > -- > paperCrane <Justin Patrin> > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

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