Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opencart - How to manually display a module inside a template file?

Let's say I want to display the specials module on the homepage in a position different than $content_top, $content_bottom, $column_left or $column_right. How do I do that? If you have some experience with this, could you give me some pointers?

The module will be display in home.tpl but I'm assuming I would need to edit the controller file home.php

like image 515
Cris Avatar asked Jan 11 '12 13:01

Cris


1 Answers

To do this, you will need to make edits to two files

Firstly, you will need to edit the controller. In this example, I'm going to add the specials to the home page

So open the controller file catalog/controller/common/home.php. Somewhere before this line $this->response->setOutput($this->render()); add the following

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

The array is the settings for the module. Note that the layout, position, status and sort order aren't included, as they're irrelevant here. I've also used special_block as a unique key for the content, to avoid it conflicting with any other items that may need rendering

Then in your template file, you just need to use <?php echo $special_block; ?> wherever you want the module to go

like image 75
Jay Gilford Avatar answered Sep 19 '22 15:09

Jay Gilford