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.

 

Show a module after a number of clicks?

Show a module after a number of clicks?

Hello everyone
I use metamod for years and i am very pleased with it.

Now after all theese years i need to know if something is possible.

Here is the situation...
Visitor enters the site and a cookie is created that counts clicks till it reaches the amount of clicks we have set in the cookie. Then if the number of click is reached, then another cookie is created that lasts for 24 hours (if this cookie exists he gets the same module when he visits site for the next 24 hours), he sees a module that prompts the user to login.

Joomla! 1.5.25
Community builder
mod_metamod 2.1

Thanks in advance

liaskas
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: Show a module after a number of clicks?

Ok, that shouldn't be too hard.

$maxclicks = 20; // adjust here as required
$show = isset($_COOKIE['showmodule']);
if ($show) {
  return XXX; // replace XXX with module id of module to show
}
$clickcounter = @$_COOKIE['clickcounter'];
if ($clickcounter < $maxclicks) {
  setcookie("clickcounter", $clickcounter + 1, time()+60*60*24*30); // 30 days expiry
} else {
  setcookie("clickcounter", 0, time()-100000); // expire the counter cookie
  setcookie("showmodule", 1, time()+60*60*24); // show the module for 1 day
}


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

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5913
Dormant:
User Info:
 
Total Users:
10778
Newest User:
negina4qx
Members Online:
0
Guests Online:
186

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