How to insert module in header tpl file in opencart 2.0?

泪湿孤枕 提交于 2019-12-13 02:39:13

问题


How to insert a module in header.tpl file in opencart 2.0 ?

I have a module. Does not have the layout position option for that module. So i need to place that manually in header.tpl file.

I am already tried this but not working for opencart 2.0.

Please any one help me.

Thanks


回答1:


In opencart 2.0 or above you can load the contoller of module :-

$data['anyname'] = $this->load->controller('modulefolder/filename');

And In that module's controller file there should be a return of what it render.Like:

return $this->load->view('default/template/modulefolder/filename.tpl', $data);



回答2:


Your code is wrong

$['special_block'] = $module = $this->getChild('module/special', array(
    'limit' => 5,
    'image_width' => 80,
    'image_height' => 80
));



回答3:


For example you have a custom module named "testmodule" under common folder

if you want to insert this module in header you need to do following thing

  1. Load controller on catalog/controller/common/header.php

     $data['testmodule'] = $this->load->controller('common/testmodule');
    
  2. Echo the following code on header template file i.e. view/theme/default/template/common/header.tpl

     <?php echo $testmodule; ?>
    

This will work



来源:https://stackoverflow.com/questions/30358240/how-to-insert-module-in-header-tpl-file-in-opencart-2-0

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