|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
do_quang_tu Smarty n00b
Joined: 18 Apr 2003 Posts: 2
|
Posted: Fri Apr 18, 2003 3:39 pm Post subject: a short way to Assign a var |
|
|
i wrote a simple function to auto add a var that has the same name-var in Smarty template like this :
Code: |
class Smarty_App extends Smarty {
function x_assign($tpl_var)
{
if (is_array($tpl_var)){
foreach ($tpl_var as $val) {
$this->_tpl_vars[$val] = $GLOBALS[$val];
}
} else {
if ($tpl_var != '')
$this->_tpl_vars[$tpl_var] = $GLOBALS[$tpl_var];
}
}
}
|
Usage : $smarty->x_assign("paging");
instead of : $smarty->assign("paging",$paging);
hope you like it |
|
Back to top |
|
David Smarty Rookie
Joined: 18 Apr 2003 Posts: 17 Location: New York, NY, USA
|
Posted: Fri Apr 18, 2003 7:36 pm Post subject: |
|
|
Ha! Amusing.
I suppose you could also have overridden Smarty's assign() with your own, calling parent::assign() as needed, instead of accessing Smarty's internals. _________________ David Mintz
http://davidmintz.org/
"Anybody else got a problem with Webistics?" -- Sopranos 24:17 |
|
Back to top |
|
do_quang_tu Smarty n00b
Joined: 18 Apr 2003 Posts: 2
|
Posted: Sat Apr 19, 2003 6:28 am Post subject: |
|
|
Thank you very much , your way's really better . |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|