Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Random modules on front page only

Random modules on front page only

Hi,

I have the following to display a single mod on the homepage ( homepage is both joomla and virtuemart homepage ):

Code:

$vm = JomGenius("virtuemart");

if ($vm and ($option != "com_virtuemart" or $vm->check("pagetype = frontpage") or $vm->page == "shop.index" ) ) return 62;

But I now want the mod displayed to be a random selection from 5 available mods. I know I need something like this incorporated:

Code:

$r = mt_rand(1,5); 

if ($r == 1) return 62;
if ($r == 2) return 69;
if ($r == 3) return 70;
if ($r == 3) return 71;
if ($r == 3) return 72;

Just not sure how to combine the two though. I've tried a few things but my coding skills are not really up to scratch !!

Grateful for any help.

Thanks a lot.

Q

qme1ster
Beginner Modder
ranks
useravatar
Offline
17 Posts
Administrator has disabled public posting

Re: Random modules on front page only

Hi,

Can anyone please help me with this ?

qme1ster
Beginner Modder
ranks
useravatar
Offline
17 Posts
Administrator has disabled public posting

Re: Random modules on front page only

Sorry for the delay - took some time off to spend with my kids in their school holidays.

Try the code this way:

Code:

$vm = JomGenius("virtuemart"); 

if ($vm and ($option != "com_virtuemart" or $vm->check("pagetype = frontpage") or $vm->page == "shop.index" ) ) {
  $r = mt_rand(1,5);
  if ($r == 1) return 62;
  if ($r == 2) return 69;
  if ($r == 3) return 70;
  if ($r == 3) return 71;
  if ($r == 3) return 72;
}

Hope that helps,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3328 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Posts this week:
4
User Info:
 
Total Users:
4383
Newest User:
kingpen99
Members Online:
0
Guests Online:
138

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