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.

 

Change Module after a certain number of visitors

Change Module after a certain number of visitors

I'm using Joomla 2.5 and MetaMod 3.17  - Module "Random Image"

Is it possible to show the module only for a certain number of sitevisits (each visit of the site, not a particular user) and as soon as the site has had for example 10.000 visits the module changes and shows something else?

If yes - what do I have to do to make it work ?

siggi
Beginner Modder
ranks
useravatar
Offline
1 Posts
Administrator has disabled public posting

Re: Change Module after a certain number of visitors

Hi Siggi,

I suggest that you create a new table in your database called (your_prefix)_randomimage
In that table, create a 2 columns:

id, of type int
viewcount, of type "int"

Insert a new record with values id=1, count=0

Then in MetaMod, use the following PHP:

Code:

// get existing value

$query = 'select viewcount from #_' . '_randomimage where id = 1';
$db->setQuery($query);
$value = (int)$db->loadResult();
// increment value
$value++;
// replace value in database
$query = 'update  #_' . '_randomimage set viewcount = ' . $value . ' where id = 1';
$db->setQuery($query);
$db->query();// note in Joomla 3, change query() to execute()

if ($value > 10000) return XXX;
return YYY;
// replace XXX with module id of module to show after 10,000 views
// replace YYY with module id of module to show from 0-10,000 views

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
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1698
Total Polls:
6
Total Posts:
5944
Dormant:
User Info:
 
Total Users:
5595
Newest User:
gary099231
Members Online:
1
Guests Online:
547

Online: 
gary099231

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked