Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » time online (sessions)
time online (sessions)
time online (sessions)
Has anyone been able to display a module based on how long a given viewer (not registered or logged in) has been on a site?
Perhaps using sessions information?
I have a few modules that i would like up for the first few moments when a person come to the site but after awhile i would like for them to be gone and out of he way for a much cleaner site. And i don't want members to have to see them at all if they are logged in.
Re: time online (sessions)
There's an example of showing a module once per session in this recipe page: http://www.metamodpro.com/support/recip … er-session
You can easily modify this to only show the modules to non-logged-in users. In fact, you should just be able to use the "Show Quick module(s) to" selector to restrict the access to only people who are not logged in. (despite the label, it affects the PHP rules as well as the Quick Module ID Include).
Does "once per session" cover your needs, or do you really want to show the module, for example, "on every page for the first 5 minutes someone is on the site" ? That's certainly achievable, just takes a little longer to code.
Hope that helps,
Stephen
Re: time online (sessions)
Does "once per session" cover your needs, or do you really want to show the module, for example, "on every page for the first 5 minutes someone is on the site" ? That's certainly achievable, just takes a little longer to code.
If he dont need it i surely do. Can someone help?
Re: time online (sessions)
Ok, here's how to make the modules only appear for the 1st 10 minutes of any user session. So if they come back in a different session, then the modules will re-appear for the 1st 10 minutes.
if ($MM_LOGGED_IN) return; // short-circuit: return nothing if user is logged in
$session =& JFactory::getSession();
$starttime = (int)$session->get('modulestarttime');
$seconds = 10 * 60; // 10 * 60 = 10 minutes
$moduleid = XXX; // replace XXX with the module id of the module to display
if ( $starttime == 0 ) {
$session->set( 'modulestarttime', time() );
return $moduleid; // they just entered the site
}
if ($starttime + $seconds > time() ) {
return $moduleid;
}
- Index
- » MetaMod
- » MetaMod General Support
- » time online (sessions)
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5943
- Posts this week:
- 2
- User Info:
- Total Users:
- 7642
- Newest User:
- mary26
- Members Online:
- 0
- Guests Online:
- 168
- 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