Re: Question about smarty, and if it can replace PHPLIB
| From: | Andr� Rabold | Date: | Wed, 19 Feb 2003 14:08:01 +0000 |
| Subject: | Re: Question about smarty, and if it can replace PHPLIB | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7868@lists.php.net to get a copy of this message | ||
Here's an example how you could do that:
NEWS.PHP
-------------
class newsModule {
// [...]
function getOutput() {
$smarty = new Smarty();
// [...]
// now parse news.tpl and return output of it
return $smarty->fetch("news.tpl");
}
}
INDEX.PHP
--------------
// [...]
$content = $newsModule->getOutput( );
$smarty = new Smarty();
$smarty->assign("CONTENT", $content);
$smarty->display("index.tpl");
// [...]
Hope I understood you correct ;-)
bye,
André
"Tom Sommer" <webmaster@tsn.dk> schrieb im Newsbeitrag
news:20030219135552.58346.qmail@pb1.pair.com...
> Currently I am building a website of PHPLIB templates, however I have seen
> benchmarks where smarty is much faster and PHPLIB is starting to bug me
with
> blocks etc., so I am thinking of making a fast change to smarty...
however,
> I have come to find the very good way of creating templates, her is how
I've
> built them
>
> <html>
> <title>{TITLE}</title>
> <body
> {CONTENT}
> </body>
> </html>
>
> Now, I have this in a main file called index.tpl, and on news.php I load
> another tpl along with index.tpl (lets call it news.tpl) file, add
variables
> to it and then redirect the final parsing of news.tpl to the variable
> CONTENT (I also set the TITLE var in news.php) in index.tpl... and finally
> displaying index.tpl on news.php (with news.tpl as CONTENT)
>
> ....... can smarty do this?
>
> Hope you understand my little config here :)
>
> I don't want to hear about including top and bottom headers, since I've
> worked that way for a long time and have come to love my new way of
working
> with templates :)
>
> Thanks for any help :)
> --
> Tom Sommer
> www.tsn.dk - www.dreamcoder.dk
>
>
>