webdevanuj
webdevanuj

Reputation: 675

How to show custom module direct in catalog tpl file in oc2

I have read all the related questions in SO and Opencart Forum but couldn't find solution.

So I have copy featured module and edited some of code, not too much and Now i want to show this new module direct in front on only success page. So i have put this code in catalog/controller/checkout/success.php

$data['successpage'] = $this->load->controller('module/successpage');


and in ***catalog/view/theme/default/template/common/success.tpl

<?php echo $successpage; ?>

Now i getting

error Undefined index: limit in controller\module\successpage.php on line 20


* I think its b'coz some variables values need to send in module controller file

And i have try all the answer for this but can't get solution.


Thanks If you know and help me to sort out.

Upvotes: 0

Views: 150

Answers (2)

Vidhyut Pandya
Vidhyut Pandya

Reputation: 1619

You might get an error as there is not any settings (data) is passed in index method of your class ControllerModuleSuccesspage. You are directly calling $data['successpage'] = $this->load->controller('module/successpage');

Try to display your successpage module by setting from admin side. (From layout). If you want to call it directly then first check for condition if ($setting['any index']) { ..... } else {... }.

If you want to pass any parameter without setting up from admin side than do this.

$parameters = array(
 'name' => 'Your module name',
 'product' => array(43,40,42,30), // product id
 'limit' => 4,
 'width' => 200 ,
 'height' => 200,
 'status' => 1
);

$data['successpage'] = $this->load->controller('module/successpage',$parameters);

You will get all details of $parameters in index method of your successpage controller file. That's it. :)

Upvotes: 1

Pritam Parua
Pritam Parua

Reputation: 692

Try this url " [yourhost]/index.php?route=module/successpage" to see if this module is working perfectly. There is no error in loading this module to parent controller. I think issue is present in this module itself. Maybe some value dependency.

Upvotes: 0

Related Questions