Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Only show module after 3 page visits
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;
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
- Index
- » MetaMod
- » MetaMod General Support
- » Only show module after 3 page visits
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5942
- Posts this week:
- 2
- User Info:
- Total Users:
- 7628
- Newest User:
- horlogekorting34
- Members Online:
- 1
- Guests Online:
- 180
- Online:
- horlogekorting34
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked