Php 指定模板变量的Prestashop Ajax显示

Php 指定模板变量的Prestashop Ajax显示,php,prestashop,Php,Prestashop,如何在displayajax()函数中显示“分配的模板变量”(我使用的是prestashop 1.5.6.0) 如果您访问: 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 但如果你去: sitedomai

如何在displayajax()函数中显示“分配的模板变量”(我使用的是prestashop 1.5.6.0)

如果您访问:

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
但如果你去:

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";
}
如何访问通常在prestashop的调试控制台中看到的所有“分配的模板变量”…如$combines$groups


谢谢大家!

分配的模板变量可以通过以下代码返回:

    public function displayAjax()
    {
        $array= $this->context->smarty->tpl_vars['combinations'];
        foreach($array as $k => $v)
        {
            //some code
        }
    }
$this->context->smarty->getTemplateVars();
或者,如果您需要特定的变量:

$this->context->smarty->getTemplateVars('combinations');
方法getTemplateVars()返回这些变量,因此您可以使用标准函数转储这些变量:

var_dump($this->context->smarty->getTemplateVars());
您可以在displayAjax()方法中添加此选项

如果调试参数设置为(默认情况下为SMARTY_debug)类似url,也可以调用调试窗口

index.php?id_product=1&controller=product&ajax=1&SMARTY_DEBUG
使用以下displayAjax()

将弹出窗口