2015-08-18 46 views
0

我創建了一個smarty變量給控制器(OrderController.php)。 顧客選擇一個值,他的選擇在這個變量中。這工作完美。Smarty變量在控制器到tpl

現在,我想在我的後臺(tpl文件)中使用此變量(值)來顯示值。我怎樣才能做到這一點 ?

回答

1

在ordercontroller.php

$ smarty->分配( 「MYVAR」,$ MYVAR); //這個變量賦給smarty。

現在在你想要顯示這個變量的tpl文件中使用語法。

{$ myvar}它會顯示變量的內容。

+0

我有一個錯誤: [8]未定義指數:choix_magasin [8]試圖獲得非對象 – Serial42

+0

我在ordercontroller.php指派的屬性:$ smarty->分配( 'choix_magasin',$結果) ;和.tpl(後臺的_shipping.tpl):{$ choix_magasin} – Serial42

+0

嘗試調試tpl中的數組值。 {$ choix_magasin | @print_r}我認爲索引8沒有價值 –