Module Prestashop:在Admincontroller中显示简单页面(不带ObjectModel)

Module Prestashop:在Admincontroller中显示简单页面(不带ObjectModel),module,prestashop,templating,Module,Prestashop,Templating,我想在Prestashop后台创建一个简单的页面。我不需要任何对象模型 我已经创建了一个新的管理选项卡。我的问题出在管理员控制器上 您可以看到以下代码:变量不会传输到模板文件。我不知道怎么做 class AdminAzertyController extends AdminController { public function initContent() { parent::initContent(); // Le template sma

我想在Prestashop后台创建一个简单的页面。我不需要任何对象模型

我已经创建了一个新的管理选项卡。我的问题出在管理员控制器上

您可以看到以下代码:变量不会传输到模板文件。我不知道怎么做

class AdminAzertyController extends AdminController
{

    public function initContent()
    {

        parent::initContent();

        // Le template smarty

        $tpl_path = _PS_MODULE_DIR_ .'paniersdegout/views/templates/admin/view.tpl';
        $tpl = $this->context->smarty->createTemplate($tpl_path, $this->context->smarty);
        $content = $tpl->fetch();      
        $this->context->smarty->assign('content', $content);

        // Le passage de variable
        $this->context->smarty->assign('test', 'test');

    }
}   

要在自定义控制器中呈现自定义tpl文件,可以使用smarty分配内容

例如,如果必须呈现自定义模块的customtemplate.tpl文件

 public function initContent() {

        parent::initContent();

       $content = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'custommodule/views/templates/admin/customtemplate.tpl');

        $this->context->smarty->assign(
                array(
                    'content' => $this->content . $content,
                )
        );
}

我认为您是在为模板分配变量之前获取模板内容。您应该在获取之前传递变量。祝你好运