2014-10-27 115 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