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条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?