Opencart 2 load layout by id

2019-09-11 08:32发布

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 ?

标签: opencart2.x
1条回答
看我几分像从前
2楼-- · 2019-09-11 09:03
//loading Layout

=> While adding/Editing Information page under the Design Tab you can overwrite layout dynamically which is preferable. enter image description here

=> 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

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

if you want to load custom template for particular information page, you can pass custom tpl file on your condition, create yourfile.tpl

go to 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));
}
查看更多
登录 后发表回答