Re: [SMARTY-DEV] feature request

From: Date: Mon, 05 Jan 2004 17:29:19 +0000
Subject: Re: [SMARTY-DEV] feature request
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2028@lists.php.net to get a copy of this message
> Although there are some big issues: > > [...] - To avoid having redundant calls, some way of > caching has to be implemented, but the code becomes > more complicated. I don't see a need for caching as such. The first time any (say) "news" field is used, I'd pull the whole news article from the database, and assign all the relevant vars. If there were no references to the news article in the template, one query saved. If there are several, then it's still only one query. The overhead from reading multiple vars and storing the results when only one is needed is minor compared with the potential for saving a complete query. I personally think that the idea for having a function called whenever a variable is first accessed which is undefined is a good one. I am thinking, amongst other things, of how one could rewrite a CMS system like *Nuke using Smarty templates. One of the key requirements would be the ability to put any module I wanted anywhere in the template, but I wouldn't want the code for (say) a voting module called unless I put the module on the page. Putting the module into a custom function moves the presentation of the module into the code, not in the template, which completely goes against the code separation principle. One alternative which comes to mind is an assign_by_func() method, ie: [news.html] function get_news() { ... return $news; } $smarty->assign_by_func('news', 'get_news'); [news.tpl] {$news.id} {$news.author} -- Mark Rogers, More Solutions Ltd :: Tel: 0845 45 89 555

« previous php.smarty.dev (#2028) next »