Re: [SMARTY-DEV] feature request
| From: | Armand Turpel | Date: | Thu, 22 Jan 2004 13:57:12 +0000 |
| Subject: | Re: [SMARTY-DEV] feature request | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-2061@lists.php.net to get a copy of this message | ||
Hi,
>Monte wrote:
>Lazy loading variables can certainly have its performance issues, but
>there are times when this is useful. For example, if you want to get
>some information about an article, you could write a custom function:
>{get_article_info id=$art_id value="author"}
>This way if the template designer needs some information about the
>article (such as the author), they can get this at runtime. This may
>actually help performance since all the article data isn't needlessly
>assigned before hand on every page load.
I'm working on a cms that works exactly like this. Textes are stored in a categories tree.
Here are 2 simple examples:
1) Show a text from a db.
{op_doc name="doc" id_doc=$id_doc fields="title,text"}
{$doc[0].title}<br>
{$doc[0].text}<br>
$id_doc comes from a $_GET variable
2) Show all subcategories of a given category
$id_cat comes from a $_GET variable
{op_doccat_sub name="subcat" id_cat=$id_cat fields="id_cat,title"
order="title"}
{section name="s" loop=$subcat}
<a
href="index.php?tpl=cat&id_cat={$subcat[s].id_cat}">{$subcat[s].title}</a>
<br>
{/section}
Here the url point to the template "cat.tpl"
So the control of what to displaying is placed in the templates. It give you all the flexibility to
do what you want in the templates.
For more information:
http://www.open-publisher.net