Opencart 2 load layout by id

放肆的年华 提交于 2019-12-25 06:39:11

问题


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 ?


回答1:


//loading Layout

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

=> 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));
}


来源:https://stackoverflow.com/questions/32395406/opencart-2-load-layout-by-id

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!