Reputation: 1814
in brif
I am trying to hide or unpublished a module with another component. Anybody know how to enable/disable a module for an specific menu item from code?
Scenario:
I am using the T3 to build my templates.
I use a component call Jreviews that list events and it is possible to customize views. The component it is assigned by a joomla menu item.
I also asign a banner component to the top of the same menu item.
I only want the banner component the first time the page is load but not when the user search within the Jreviews component. (after the search joomla stay in the same url)
I can catch the search event within the Jreviews component and render a module by position.
<?php
$position = 'user1';
$params = array('style'=>'');
$document = &JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$contents = '';
foreach (JModuleHelper::getModules($position) as $mod) {
$contents .= $renderer->render($mod, $params);
}
echo $contents;
?>
Question
how to show the module banner component ONLY when i load it by code with in the Jreview template?
Thanks a lot,
Eduardo
Upvotes: 1
Views: 1964
Reputation: 1814
I found the way just adding the folowing code
<?php
$position = 'show-by-code';
$params = array('style'=>'');
$document = &JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$contents = '';
foreach (JModuleHelper::getModules($position) as $mod) {
$contents .= $renderer->render($mod, $params);
}
echo $contents;
?>
Then in the module administration i use the same position 'show-by-code' that is not part of my template.
Upvotes: 1
Reputation: 42622
If you can, try catching the event also in the module code and making there the decision if it should display the banner or not.
Upvotes: 0