duanjunao9348 2013-10-14 17:47
浏览 59
已采纳

Prestashop Ajax显示已分配的模板变量

How do I display the "assigned template variables" inside a displayajax() function (I am using prestashop 1.5.6.0).

If you go to:

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

but if you go to:

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

to have some output in that page I added this function in ProductController.php and it works:

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

How can I access all the "assigned template variables" that I see usually in the debug console of prestashop...like $combinations $groups...

Thank you!

  • 写回答

2条回答 默认 最新

  • douwa6220 2013-10-14 20:38
    关注

    The assigned template variables can be returned via the following code:

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

    or if you need a specific variable:

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

    the method getTemplateVars() returns those variables, so you may dump it with the standard function:

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

    you can add this at the displayAjax() method.

    You can also call the debug window if the debug param is set (by default SMARTY_DEBUG) so url like

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

    with the following displayAjax():

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

    will popup the window.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码