There is no function
getCategoryLayouts($category_id) in
catalog/model/catalog/category.php
There is
getCategoryLayoutId($category_id) but that is useless to hide/show dynamic content.
Normally,modules which are defined in a layout are executed when that layout is used, no additional control there, it is a static definition.
If you want a module, defined there, not to be executed under certain conditions, you need to do that in the module itself.
In the module's index function you simply add as the first line:
if (your condition) return;
Then that module returns nothing.
To check what kind of page you are on you check the route as in
$this->request->get['route']
which would get you
product/category or
product/product or
information/information etc.
to check for a specific page on a route you check if a certain id is set as well like
$this->request->get['product_id'] or
$this->request->get['information_id']
for route
$this->request->get['route'] = 'product/category' you check
$this->request->get['path'] and if that has a _ in it you need to extract the last number to get the category id
so if you have module bestsellers defined in the layout for all product pages but do not want it to show for some products you would edit the bestsellers module first line after index():
Code: Select all
if (isset($this->request->get['route']) && $this->request->get['route'] == 'product/product') {
$product_id_exclude = array(12,43,22);
if (isset($this->request->get['product_id']) && in_array($this->request->get['product_id'],$product_id_exclude)) return;
}
Then again, if you have a module which is very dynamic in terms of when and what to show, I would suggest not to use the layout but simply control it via the controllers and call that module there based on conditions of when to show and give the module parameters to control what to show (like product id exclusion).
controller:
Code: Select all
$data['content'] = false;
if (your condition) {
$setting = whatever you need and controller accepts
$data['content'] = $this->load->controller('route_to_module_controller',$setting);
}
twig:
Code: Select all
{% if content %}{{ content}}{% endif %}