php - 为什么我不能在 prestashop 1.7 的主题中嵌入我的模板?
问题描述
我正在尝试遵循 prestashop 的官方指南,但我面临两个问题:
- 我将 display.tpl 视为原始文本,而不是嵌入到主题中。
- 我看不到存储在变量“my_module_message”中的消息
g2a.php(主模块文件)
public function hookDisplayLeftColumn($param)
{
$this->context->smarty->assign(
array(
'my_module_name' => configuration::get('G2A_NAME'),
'my_module_link' => $this->context->link->getModuleLink('g2a','display'),
'my_module_message' => $this->l('This is a simple text message')));
return $this->display(__FILE__ , 'g2a.tpl');
}
控制器/前端/display.php
class g2adisplayModuleFrontController extends ModuleFrontController
{
public function initContent()
{
parent::initContent();
$this->context->smarty->assign('my_module_message', $this->l('This is a simple text message'));
$this->setTemplate('module:g2a/views/templates/front/display.tpl');
}
}
视图/模板/front/display.tpl
{extends file=$layout}
{block name='content'}
welcome to my shop!
{$my_module_message}
{/block}
解决方案
代码中的所有内容都是正确的,但是因为我在管理面板中禁用了缓存,所以我认为这不是缓存问题。
管理>配置>高级参数>性能> Smarty >模板编译>如果文件已更新,则重新编译模板。
推荐阅读
- javascript - 如何将工作 HTML、CSS、Javascript 代码从 Codepen 传输到 Visual Studio 代码和浏览器
- mysql - Sql 在简单查询上抛出错误
- c# - 当sql语句包含@时如何将Dapper与mysql一起使用
- html - 没有 javascript 的交互式页面加载
- cakephp - fontawesome-webfont.ttf:1 在 cakephp 2.10.12 中找不到
- excel - 将数字存储为文本时如何使用带有大于或等于运算符的 Excel SUMIFS
- python - 如何在 Flask-SQLAlchemy 中按用户获取不同列条目的数量?
- java - Java JDBC ActiveDirectoryAuthentication Azure SQLServer 失败并出现 401 /adfs/services/trust/13/windowstransport 异常
- bluetooth - 为什么 Fido 在网络蓝牙中被阻止而不是 USB
- ios - 为 UIButton 启用自动调整大小会禁用图像背景