Prestashop中的Smarty分配未分配数组

时间:2018-11-28 23:37:12

标签: php mysql prestashop smarty

我想从数据库prestashop类别信息中获取模块信息,并且我使用sql查询,但是如果我尝试分配foreach数组prestashop,则重新生成错误代码:Parse error: syntax error, unexpected 'return' (T_RETURN)

这是我的代码

    public function hookDisplayHome()
    {
    $getcategory = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'category_lang`');
    $cattegoryinfo=array();
    foreach($getcategory as $getcategoryinfo){
        $cattegoryinfo[] = array(
         "name" => $getcategoryinfo['name']
         );
    }
         $this->context->smarty->assign('categories', $cattegoryinfo);
         return $this->display(__FILE__,'views/showcategory.tpl');
}

2 个答案:

答案 0 :(得分:1)

我测试了您的代码,并在“;”之后找到了一个特殊字符。在这一行:

$this->context->smarty->assign('categories', $cattegoryinfo);

将其删除,然后重试

答案 1 :(得分:0)