如何检查特定值是否已分配给Smarty,如果没有分配(默认)值?
回答:
if ($this->cismarty->get_template_vars('test') === null) { $this->cismarty->assign('test', 'Default value'); }
Andy.. 15
Smarty 2
if ($smarty->get_template_vars('foo') === null) { $smarty->assign('foo', 'some value'); }
Smarty 3
if ($smarty->getTemplateVars('foo') === null) { $smarty->assign('foo', 'some value'); }
请注意,对于Smarty 3,您将不得不使用$smarty->getTemplateVars
.
Smarty 2
if ($smarty->get_template_vars('foo') === null) { $smarty->assign('foo', 'some value'); }
Smarty 3
if ($smarty->getTemplateVars('foo') === null) { $smarty->assign('foo', 'some value'); }
请注意,对于Smarty 3,您将不得不使用$smarty->getTemplateVars
.