Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
550 views
in Technique[技术] by (71.8m points)

opencart2.x - Opencart 2 load layout by 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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
//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));
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...