Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Random Modules
Random Modules
Random Modules
So I have a couple of modules that are based on mod_rquotes that I want to randomly display at a site. One module is titled "Leave No Trace" that we randomly have the "Leave No Trace" principles displayed and the other is "The Ten Essentials" that we randomly have the essential things to take with you when you are hiking. Right now I have mod_rquotes set up to randomly display each 'quote' at each page request. So what I would like to do is randomly have the "Leave No Trace" module and "The Ten Essentials" module appear at each page request. Hope that made sense. My guess is that there is probably some kind of PHP trick that I would use to do that but it escapes me.
Re: Random Modules
Hi Sackerman,
there's a recipe for doing random selection: http://www.metamodpro.com/support/recip … s-randomly
If it's a 50-50 split between the 2 modules, then I'd do the following:
if ( rand( 1,2 ) == 1 ) return 101;
else return 102;
(replace 101 and 102 with the module numbers of the modules you want to randomly display).
Cheers,
Stephen
Re: Random Modules
Thanks! I thought that I had looked at the recipes but apparently not (RTFM I guess ;-) Now to really add some icing on the cake, is there a way of pulling the different module class suffixes for each one so that the styles vary based on the included module?
Re: Random Modules
See http://www.metamodpro.com/support/contr … parameters
After you've decided which module to include, use syntax something like:
$changes->mod(101)->setParam('moduleclass_sfx','-mysuffix');
return 101;
So overall the rule might be:
if ( rand( 1,2 ) == 1 ) {
$changes->mod(101)->setParam('moduleclass_sfx','-mysuffix');
return 101;
}
else {
$changes->mod(102)->setParam('moduleclass_sfx','-mysuffix2');
return 102;
}
This assumes PHP5. If youare using PHP4 this will either not work or give an error... let me know if that's the case and I'll try to remember how to do it in PHP4.
- Index
- » MetaMod
- » MetaMod General Support
- » Random Modules
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5943
- Posts this week:
- 2
- User Info:
- Total Users:
- 7642
- Newest User:
- mary26
- Members Online:
- 0
- Guests Online:
- 182
- 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