How to insert module in header tpl file in opencar

2019-08-10 21:14发布

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

标签: opencart2.x
3条回答
一纸荒年 Trace。
2楼-- · 2019-08-10 21:39

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);
查看更多
小情绪 Triste *
3楼-- · 2019-08-10 21:47

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

查看更多
迷人小祖宗
4楼-- · 2019-08-10 21:53

Your code is wrong

$['special_block'] = $module = $this->getChild('module/special', array(
    'limit' => 5,
    'image_width' => 80,
    'image_height' => 80
));
查看更多
登录 后发表回答