OpenCart 2按ID加载布局 [英] Opencart 2 load layout by id
问题描述
在opencart中,我具有信息布局ID,这是自定义的,不是默认设置.如何通过此ID加载自定义布局?
In opencart I have Information layout id, it's custom not default. How I can load custom layout by this id ?
在其中一个信息页面中可以有自定义模板吗?
It posible to have custom template in one of information pages ?
推荐答案
//loading Layout
=> 在设计"选项卡下的添加/编辑信息"页面中,您可以动态覆盖布局,这是可取的.
=> While adding/Editing Information page under the Design Tab you can overwrite layout dynamically which is preferable.
=> ,或者您可以根据自己对每个文件contente_top, content_button, column_left and Column_right
的条件手动传递layout_id
,我不建议这样做.
=> or you can pass manually layout_id
based on your condition on each file contente_top, content_button, column_left and Column_right
, which i dont recommand.
$modules = $this->model_design_layout->getLayoutModules($layout_id, 'column_left');
//Creating Layout
要创建自定义布局,您首先需要创建New Controller&查看(找到此处),然后,您可以继续添加自己的布局admin/system/design/layout
用于新的Controller(Rout)
To create a custom layout, you first need to create New Controller & View (findhere), after that you can add your own layout by going onadmin/system/design/layout
for your new Controller(Rout)
//loading custom template
如果要为特定信息页面加载自定义模板,则可以根据情况传递custom tpl
文件,创建yourfile.tpl
if you want to load custom template for particular information page, you can pass custom tpl
file on your condition, create yourfile.tpl
转到catalog/controller/information/information.php:49
在这里检查条件,并通过您的查看图块.
here check the condition and pass your view tile.
if($information_id==your_condition){
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/information/yourfile.tpl', $data));
}else{
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/information/information.tpl', $data));
}
这篇关于OpenCart 2按ID加载布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!