我无法将变量从我的php文件传递给我的smarty文件

问题描述 投票:-1回答:1
public function hookDisplaySlider() {
    $this->context->smarty->assign('test', "test");
   // $sql = 'SELECT * FROM '._DB_PREFIX_.'slider';
   // $result = Db::getInstance()->getValue($sql);
   // $this->context->smarty->assign('query_results', Db::getInstance()->getValue($result));

  return $this->display(__FILE__,'views\templates\hook\dplus_slider.tpl');
}

我的文件smary

<p>{$test}</p>

我的tpl文件正确读取了html代码,但无法读取我可以放入其中的变量

php prestashop smarty
1个回答
0
投票

尝试一下:

    $this->context->smarty->assign(array(
         'test' => "test"
    ));
© www.soinside.com 2019 - 2024. All rights reserved.