Re: [SMARTY] modularizing templates, ala 'BLOGS'
| From: | Monte Ohrt | Date: | Tue, 11 Feb 2003 18:21:49 +0000 |
| Subject: | Re: [SMARTY] modularizing templates, ala 'BLOGS' | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7643@lists.php.net to get a copy of this message | ||
First separate each module into its own template. Anytime you want a
module on your page, you just include it:
{include file="weather.tpl"}
Now to make this a true standalone module, you need to load the content
into the template at the time it gets included.
I'd recommend these two methods:
1) use {include_php file="load_weather.php"} at the top of your weather
template. This would be a php script that does the duty of
loading/assigning the weather content. It might look like this:
<?php
global $sql;
// get weather data from db
$sql->query("select * from weather", SQL_ALL);
// assign it to the current smarty object
$this->assign('weather_data', $sql->results);
?>
2) in Smarty 2.4.0, you can use a registered/assigned object to do the
same task {weather->getinfo} or {$weather->getinfo()}
Then after the content is loaded, the template displays the content as
usual.
Monte
On Tue, 2003-02-11 at 10:50, Dennis Gearon wrote:
> Anyone got any links or comments on how to do pages like BLOGS do where different modules
> handle
> different parts of the display?
>
> For example, like PHPNuke/PostNuke has a weather posting module, a login module, a horoscope
> module, a survey module, etc?
>
>