问题
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