feature request

From: Date: Sun, 04 Jan 2004 17:41:46 +0000
Subject: feature request
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2018@lists.php.net to get a copy of this message
Hi all, I have a feature request. I'll explain what I'm thinking off: I want to give the template designers as much information as possible. But assigning all the possible variables (with the assign() function) is useless, because most of the times the template designer doesn't user all the variables, so there may be unneeded database queries (for example) to set all variables. Therefore, it might be a good idea only to retrieve the information when the user asks for it. This can be detected when the template asks for a variable {$var} that isn't set yet. So my request is: a function in class Smarty that will be called when the template asks for a variable that isn't set yet (so I can override Smarty and implement the function) OR a system similar as the plugins (http://smarty.php.net/manual/en/plugins.php) so I can register my own function as 'call when template asks for unknown variable'. Besides this, I don't know if this is a good method of programming: a template may ask, for example, 'topic_name' and I detect that variable isn't set yet => I get it from the database. But after this, the template asks for 'topic_text' and I detect again that variable isn't set yet => I get it from the database. But now I have 2 queries (for 'topic_name' and 'topic_text') which could be combined into one query => overhead because in this situation 2 queries will take more time than 1 query. An option might be to retrieve 'topic_text' also when the template asks for 'topic_name', and cache/store it in memory. But what about the situation when 'topic_text' is NOT called in the template => overhead because I retrieved too much information, so the query takes more time than needed. Kind regards, Peter

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