2014-10-27 78 views
0

为什么在我测试/ nl/nl/address时,smarty变量在我的代码中没有价值?空smarty变量?

代码:

{php} 
    global $country; global $lang; 
    $this->assign('curLang',$lang); 
    $this->assign('curCountry',$country); 
{/php} 
{if $curLang == "nl" && ($curCountry == "nl" || $curCountry == "be")} 
    {literal} 
    javascript code 
    {/literal} 
    {assign name="test" value="1"} 
{/if} 
{$curCountry} <!-- nl --> 
{$curLang} <!-- nl --> 
{$test} <!-- Empty value --> 
+0

也许你如果不执行的语句... – gskema 2014-10-27 18:21:47

+0

@GytisŠk我编辑我的帖子。奇怪的行为 – user3105439 2014-10-27 18:33:57

回答

0
{assign name="test" value="1"} 

不,

{assign var="test" value="1"} 

{$test} 

使用name =这样http://www.smarty.net/docs/en/language.function.assign.tpl

+0

非常感谢你应该是var而不是名字 – user3105439 2014-10-27 18:46:30

+0

对于投票来说,速记{assign'test'1}更容易记住,取决于你是否更容易消费,并找出你回来的时候虽然。 – Cups 2014-10-27 18:51:12