2013-10-14 59 views
0

如何顯示displayajax()函數(我用的Prestashop 1.5.6.0)裏面的「分配模板變量」。分配的模板變量的Prestashop阿賈克斯顯示

如果你去:

sitedomain/index.php?id_product=1&controller=product you see the product 

,但如果你去:

sitedomain/index.php?id_product=1&controller=product&ajax=true you see a blank page 

能夠在同一頁我ProductController.php添加了這個功能,一些輸出,它的工作原理:

public function displayAjax() 
{ 
    echo "something"; 
} 

我如何可以訪問所有的「分配模板變量」,我通常看到PRES的調試控制檯tashop ......像$ $組合組...

謝謝!

回答

1

所分配的模板變量可以通過以下代碼返回:

$this->context->smarty->getTemplateVars(); 

,或者如果你需要特定的變量:

$this->context->smarty->getTemplateVars('combinations'); 

方法getTemplateVars()返回這些變量,

var_dump($this->context->smarty->getTemplateVars()); 
:這樣你就可以與標準功能轉儲10

您可以在displayAjax()方法添加此。

您也可以撥打調試窗口,如果調試參數是設置(默認情況下SMARTY_DEBUG)這樣的URL一樣

index.php?id_product=1&controller=product&ajax=1&SMARTY_DEBUG 

具有以下displayAjax():

public function displayAjax() 
{ 
    $this->context->smarty->display($this->context->smarty->getDebugTemplate()); 
} 

會彈出窗口。

0
public function displayAjax() 
    { 
     $array= $this->context->smarty->tpl_vars['combinations']; 
     foreach($array as $k => $v) 
     { 
      //some code 
     } 
    }