AW: [SMARTY] Nested templated
| From: | Werner Schweizer | Date: | Tue, 16 Sep 2003 20:50:34 +0000 |
| Subject: | AW: [SMARTY] Nested templated | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-10227@lists.php.net to get a copy of this message | ||
I'm doing it that way:
--- master.tpl (in pseudocode)
{master}{*This calls the plugin smarty_function_master
which assigns $Content by fetching the required template*}
!DOCTYPE ....
<html>
<head>
<meta ...
<script ...
<style ...
<title ...
</head>
<body>
{$Content}
</body>
</html>
--- function.master.php
function smarty_function_master($params, &$smarty)
{
$tplId = $smarty->_tpl_vars['ApplVars']['TemplateId'];
$cplId = $smarty->_tpl_vars['ApplVars']['CompileId'];
$template = $smarty->_tpl_vars['ApplVars']['Template'];
$caching = $smarty->caching;
$smarty->caching = false;
$smarty->assign('Content', $smarty->fetch($template.'.tpli', $tplId,
$cplId));
$smarty->caching = $caching;
}
Where ApplVars is an array with contents depending on URL-parameters
and a site description written as XML file.
Each template calls itself a smarty-function (plugin) to assign its own
content variable.
The templates and the called functions have access to ApplVars
where they can find the URL parameters and the corresponding part
of the site description.
MfG
Werner
> -----Ursprüngliche Nachricht-----
> Von: Alvaro Nunes Melo [mailto:al_nunes@atua.com.br]
> Gesendet: Montag, 15. September 2003 12:22
> An: Smarty - General
> Betreff: [SMARTY] Nested templated
>
>
> Hi,
>
> I just can't calculate how many time I'd lost because I didn't knew
> templates structure and, most specifically, smarty. But I
> don't know how
> to solve a problem using it: nested templates.
>
> I have a tamplate for the main page, and inside of it I need
> to include
> (dynamically), templates of other components of my pages. Is there any
> way to do this?
>
> Best regards,
> --
> +---------------------------------------------------+
> | Alvaro Nunes Melo Atua Sistemas de Informacao |
> | al_nunes@atua.com.br www.atua.com.br |
> | UIN - 42722678 (54) 327-1044 |
> +---------------------------------------------------+
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>