Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » One MetaMod Pro Control modules in...
One MetaMod Pro Control modules in various positions
One MetaMod Pro Control modules in various positions
Hi,
I would like to check if following is possible:
I have a XXX module in the breadcrumb position and another YYY module in the sidebar position. These modules should only appear when certain rules are met e.g. when url contain certain keywords
With metamod pro (MMP), can I use only one MMP module and put it into the breadcrumb position, and put the rules into PHP, so that when the rules are matched, the XXX module in breadcrumb and YYY module in sidebar will be visible in their respective positions? if yes, how to do it?
The only way I know is to publish 2 x MMP modules, one at breadcrumb and one at sidebar, and both using the same rules. Downside is that both MMP modules will need to be loaded and evaluated.
Re: One MetaMod Pro Control modules in various positions
If you have the Pro version, then there's another approach. Using "parameter control", one MetaMod can change the parameters (including switching a module off entirely) of any module on the page. See http://www.metamodpro.com/metamod/contr … parameters for more info.
So in this case you would assign all of the target modules into all of the module positions that you want them to appear in. e.g. if you want to toggle between 2 different modules in the sidebar, then assign BOTH of them into the sidebar, publish them both, and ensure they are both assigned to the appropriate menu items. At this point, without the MetaMod getting involved, you'll see BOTH modules appear there on all pages.
Then create a MetaMod and assign it to any position you like that appears on the page. Nothing is going to appear in that module position, you're just setting up the MetaMod as a controller.
In the MetaMod, do the following:
if (some condition here) {
$changes->mod(AAA)->disable(); // sidebar
$changes->mod(BBB)->disable(); // breadcrumbs
} else {
$changes->mod(CCC)->disable(); // sidebar alternative
$changes->mod(DDD)->disable(); // breadcrumbs alternative
}
Replace AAA-DDD with the module ids of the modules that you want to selectively disable. You can use this approach to disable multiple modules at once. Nothing will be displayed inside the MetaMod itself.
Hope that helps,
Stephen
Re: One MetaMod Pro Control modules in various positions
Wow, this is very powerful, must the modules be published status? Can they be in unpublished status?
What is the best way to handle this:
Store the keywords to match is a $names array with corresponding module ids
$names = array(
"keyword A" => "AAA, BBB"
"keyword X" => "XXX, YYY"
);
a loop to check whether the keyword exists and store into the $modules[] array the corresponding modules ids
then i just use this?
$changes->mod($modules[])->enable
Re: One MetaMod Pro Control modules in various positions
Hi,
it is a limitation that the modules must be in published status. MetaMod Pro can disable (unpublish) other modules on the page but it can't publish unpublished ones.
Here's an example recipe to turn on certain mods per keyword. You have to provide a list of all modules that you want it to control:
// these modules will get disabled UNLESS they are enabled by a certain keyword:
// (they must all be published in advance)
$all_mods = array("AAA","BBB","CCC","DDD","XXX","YYY");
// modules to enable for each keyword:
$names = array(
"keyword A" => array("AAA", "BBB" ),
"keyword X" => array("XXX", "YYY" )
);
$no_delete = array();
foreach ($names as $key=>$mods) {
if ($core_genius->check("url contains",$key)) {
$no_delete = array_merge($no_delete, $mods);
}
}
foreach ($all_mods as $mod) {
if (!in_array($mod, $no_delete)) {
$changes->mod($mod)->disable();
}
}
Hope that helps,
Stephen
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » One MetaMod Pro Control modules in...
Board Info
- Board Stats:
- Total Topics:
- 1700
- Total Polls:
- 6
- Total Posts:
- 5967
- Posts this week:
- 3
- User Info:
- Total Users:
- 8056
- Newest User:
- no21an
- Members Online:
- 0
- Guests Online:
- 224
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked