Post by letxob » Tue Aug 15, 2017 7:51 pm

I wanted to include the specials module on the product page but only if the product itself is a special.
That cannot be done via the layout manager.
So we need to do it dynamically.

in the product controller I add:

// initialize
$data['special_module_include'] = '';

// if current product is a special

if ($product_info['special']) {

// set the module name
$module_name = 'Special';

// our own module settings
$module_setting = array('limit' => 4, width => 200, 'height' => 200);

// load the module controller
$module_data = $this->load->controller('extension/module/' . $module_name);

// generate the module output
$output = $this->load->controller('extension/module/' . $module_name, $module_setting);

// set custom title
$title = '<hr><h4>More Specials</h4>';

// assign the twig variable
$data['special_module_include'] = $title.$output;
}


Then in the product.twig I include the module at the appropriate spot:

{{ special_module_include }}

Enjoy.

Newbie

Posts

Joined
Sun Jul 02, 2017 4:36 am

Post by Fabienlolo » Sat Aug 11, 2018 5:28 am

Hi letxob,
So here, you just modify the controller file with the product being special criteria and add a line ({{ special_module_include }}) in the template of the product file right?
I wish to have different category layout so to have different modules displayed depending on the category. I am thinking of 3 more layouts than the preinstalled one.
Do you recommend:
- to add a category condition like in topic viewtopic.php?t=100649 ? There they add a condition of category (by its number) in the controller file so to call another template that you need to create.
- to create new custom pages/layout with each its MVCL coding, and then after using layout override for each category with the corresponding layout? (inspired by topic viewtopic.php?t=186404)
- or to make it dynamically just like you described in the first post of this topic?
Thank you for you expertise,
Fabien OC 3.0.2

New member

Posts

Joined
Fri Jun 29, 2018 7:24 am
Location - Q.Roo, Mexico
Who is online

Users browsing this forum: No registered users and 15 guests