Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check module position in OpenCart 2.0

I was using following code for Check module position. So, It is working fine in OpenCart 1.5.6. When module Enabled in Content left & right panel so I want to hide javascript code in OpenCart

but, it is not working in Opencart 2.0

How can be achieved in Opencart 2.0?

in .tpl file

<?php if ($module['position'] == 'content_bottom' || $module['position'] == 'content_top') { ?>
//add your code Here
<?php } ?>

add in .php file

$this->data['module'] = $setting;
like image 520
HDP Avatar asked Nov 10 '22 21:11

HDP


1 Answers

I have found simple solution. This is working like charm.

Step 1

in .tpl file. (You want to that module. featured.tpl etc...)

<?php if ($module['position'] == 'content_bottom' || $module['position'] == 'content_top') { ?>
//add your code Here
<?php } ?>

Step 2

add in .php file (You want to that module. featured.php etc...)

$data['module'] = $setting;


Step 3 (if, You are used OpenCart 2.0.0.0 version)

catalog/controller/common/{content_top, content_bottom, content_right, content_left}.php,

Find the below code

if (isset($part[1]) && isset($setting[$part[1]])) {

and add the below code after

$setting[$part[1]]['position'] = basename(__FILE__, '.php');


Step 3 (if, You are used OpenCart 2.0.1.x. version)

catalog/controller/common/{content_top, content_bottom, content_right, content_left}.php,

Find the below code

$setting_info = $this->model_extension_module->getModule($part[1]);

and add the below code after

$setting_info['position'] = basename(__FILE__, '.php');
like image 74
HDP Avatar answered Nov 14 '22 22:11

HDP