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.

 

Only show module after 3 page visits

Only show module after 3 page visits

IM trying to display a module after the 3rd page visit then cookie their browser so it wont show again until the cookie expires (1 week). Im not much of a php guy but I did what I could to come up with this, yet the cookie doesn't seem to be working as the module still comes up after every visit.


session_start();
$instance_name = "module_counter1";
$c = JRequest::getInt('SeenIt', 0, 'cookie');

if (!isset($_SESSION[$instance_name]) ||
  $_SESSION[$instance_name] == "") {
  $_SESSION[$instance_name] = 0;
}
$count = ++$_SESSION[$instance_name];
if ($count < 3) return;
if ($count >= 3 and $c) return;
else setcookie( 'SeenIt', 1, time()+7*24*60*60, '/' );
return 272;

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

Re: Only show module after 3 page visits

Close! I think you are mainly missing the check for the presence of the "SeenIt" cookie. Try this:


session_start();
$instance_name = "module_counter1";
$c = JRequest::getInt('SeenIt', 0, 'cookie');
if ($c) return; // bypass here if cookie found.

if (!isset($_SESSION[$instance_name]) ||
  $_SESSION[$instance_name] == "") {
  $_SESSION[$instance_name] = 0;
}
$count = ++$_SESSION[$instance_name];
if ($count != 3) return; // only continue on 3rd page view
setcookie( 'SeenIt', 1, time()+7*24*60*60, '/' );
return 272;


Did you remember to disable module 72 so that it doesn't show up unless MetaMod includes it? Also, ensure the "quick module id or position include" box is EMPTY if you are using PHP.

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

Re: Only show module after 3 page visits

Awesome this worked!  Thanks a bunch. Love your metamod component.

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

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5913
Dormant:
User Info:
 
Total Users:
10734
Newest User:
gudad2
Members Online:
3
Guests Online:
116


Forum Legend:

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