WebmasterSite.net: PHP scripts to enable your creativity
WSN Links PHP Directory Software
PHP Scripts Webmaster Links Support Forums


Page counter
for member

Version: 2.3
printPrint


Page counter
Jumpin Jack
Member

Usergroup: Customer
Joined: Jan 13, 2005
Total Topics: 21
Total Posts: 47
Posted 02/27/06 - 07:51 PM:
quote post
#1
I want to add a page counter to my members profile page. that is stored under a custom field {MEMBERVIEWS}. I want to be able to display or sort member profile page views in toplists and other areas of the site. Something similar to the {CATVIEWS} counter. Is there currently a way to do this?

Edited by Jumpin Jack on 02/27/06 - 07:54 PM
Paul
Administrator
Avatar

Usergroup: Administrator
Joined: Dec 21, 2001
Location: Northern California
Total Topics: 56
Total Posts: 5853
Posted 03/01/06 - 06:17 PM:
quote post
#2
A clumsy but workable way to do it would be to add a member field 'views' and then stick this php in the profile template:
<?php global $amem; $amem->views += 1; $amem->update('views'); ?>


Making it count only unique views would be tricker, but you could set a cookie and test for it in the same profile template area.

_____________________
"Do things you love doing, because then it ain't work. Don't do something you don't really enjoy, because you're never going to work hard enough at it." - Bob Young, founder of Red Hat
Jumpin Jack
Member

Usergroup: Customer
Joined: Jan 13, 2005
Total Topics: 21
Total Posts: 47
Posted 03/02/06 - 09:48 PM:
quote post
#3
How do I set a cookie and test for it
Paul
Administrator
Avatar

Usergroup: Administrator
Joined: Dec 21, 2001
Location: Northern California
Total Topics: 56
Total Posts: 5853
Posted 03/02/06 - 10:14 PM:
quote post
#4
You can use WSN's makecookie('cookiename', 'value'); function, or just http://www.php.net/setcookie . To test, if ($_COOKIE['cookiename']) { do stuff }
Of course it goes without saying that if you're adding new functionality it helps to know php.

_____________________
"Do things you love doing, because then it ain't work. Don't do something you don't really enjoy, because you're never going to work hard enough at it." - Bob Young, founder of Red Hat
Jumpin Jack
Member

Usergroup: Customer
Joined: Jan 13, 2005
Total Topics: 21
Total Posts: 47
Posted 03/03/06 - 06:06 AM:
quote post
#5
Thanks, this is what I did and it works. It expires the cookie after 24hrs

<?
makecookie('{MEMBERNAME}', '{MEMBERID}', time()+(86400));
if (!$_COOKIE['{MEMBERNAME}'])
{
global $amem;$amem->views += 1; $amem->update('views');
}
?>

Paul
Administrator
Avatar

Usergroup: Administrator
Joined: Dec 21, 2001
Location: Northern California
Total Topics: 56
Total Posts: 5853
Posted 03/04/06 - 08:26 PM:
quote post
#6
It's better to set a cookie name that doesn't change (say 'profilevisit'), both to reduce potential conficts and so that when a guest registers they don't suddenly get counted again.

_____________________
"Do things you love doing, because then it ain't work. Don't do something you don't really enjoy, because you're never going to work hard enough at it." - Bob Young, founder of Red Hat
Search thread for
Download thread as


You don't have permission to post.

Please login or register.

   
 
© 2008 Paul Knierim. All rights reserved.