opencart - 如何手动显示模板文件中的模块?
假设我想在主页上与 $content_top、$content_bottom、$column_left 或 $column_right 不同的位置显示特价模块。我该怎么做?如果您有这方面的经验,可以给我一些指导吗?
该模块将显示在 home.tpl 中,但我假设我需要编辑控制器文件 home.php
Let's say I want to display the specials module on the homepage in a position different than $content_top, $content_bottom, $column_left or $column_right. How do I do that? If you have some experience with this, could you give me some pointers?
The module will be display in home.tpl but I'm assuming I would need to edit the controller file home.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,您需要编辑两个文件
首先,您需要编辑控制器。在此示例中,我将向主页添加特价商品,
因此打开控制器文件
catalog/controller/common/home.php
。在此行$this->response->setOutput($this->render());
之前的某个位置添加以下内容该数组是模块的设置。请注意,布局、位置、状态和排序顺序不包括在内,因为它们与此处无关。我还使用
special_block
作为内容的唯一键,以避免它与可能需要渲染的任何其他项目发生冲突然后在模板文件中,您只需要使用
无论你想让模块去哪里
To do this, you will need to make edits to two files
Firstly, you will need to edit the controller. In this example, I'm going to add the specials to the home page
So open the controller file
catalog/controller/common/home.php
. Somewhere before this line$this->response->setOutput($this->render());
add the followingThe array is the settings for the module. Note that the layout, position, status and sort order aren't included, as they're irrelevant here. I've also used
special_block
as a unique key for the content, to avoid it conflicting with any other items that may need renderingThen in your template file, you just need to use
<?php echo $special_block; ?>
wherever you want the module to go