UBB.Dev
Posted By: FREAK1 Topic Views Help - 09/11/2008 1:44 AM
Hi guys,

Rick suggested I put a request here so I can get a problem fixed.

Just to make it easy here is the topic...

http://www.ubbcentral.com/forums/ubbthreads.php/topics/216481/Topic_Views.html#Post216481

In a nutshell I want topic views to increase every time someone clicks on a topic, whether it be the same person looking at the information twice or two different people.

I hope this makes sense, if not please let me know.

Thanks in advance.
Posted By: blaaskaak Re: Topic Views Help - 09/11/2008 9:28 AM
Do you also want it to count if they go to a 2nd page from a topic?

That's a bit a of the problem if you really want to count every click, and not every new visit to the topic.
Posted By: FREAK1 Re: Topic Views Help - 09/12/2008 1:54 AM
I don't think a click to a 2nd page is necessary. I have members that will come to the board, leave and come back. I don't care if they do it 20 times, but I want it to count as 20 topic hits. Instead of 1 because they didn't clear a cookie.

I hope that makes sense and thanks for the reply.
Posted By: blaaskaak Re: Topic Views Help - 09/12/2008 9:49 AM
It actually makes it more difficult. You would need some mechanism that tracks if you just clicked to a new page in the topic, or visit the topic fresh.

I am thinking about the referrer variable to check for that.

You are running 7.1.1 and using spider friendly url's right?
Posted By: FREAK1 Re: Topic Views Help - 09/13/2008 2:55 AM
If it makes it easier to count as a view by clicking to a 2nd or 3rd page that's fine.

I am using 7.1.1. and spider friendly. They like to visit the site.
Posted By: blaaskaak Re: Topic Views Help - 09/14/2008 6:40 AM
ok. I'll do this coming wednesday, I have a day off then.
Posted By: FREAK1 Re: Topic Views Help - 09/17/2008 1:43 AM
Blaaskaak thank you for doing this. smile It is greatly appreciated.
Posted By: blaaskaak Re: Topic Views Help - 09/18/2008 8:15 AM
You need to modify 2 files:


find:

/scripts/showthreaded.inc.php

PHP Code
 if ($_SESSION['current_topic'] != $main_topic_id) {
$query = "
insert into
{$config['TABLE_PREFIX']}TOPIC_VIEWS
(TOPIC_ID)
values
( ? )
"
;
$dbh -> do_placeholder_query($query,array($main_topic_id),__LINE__,__FILE__);
$_SESSION['current_topic'] = $main_topic_id;
}


Replace with:

PHP Code
//	if ($_SESSION['current_topic'] != $main_topic_id) {
$query = "
insert into
{$config['TABLE_PREFIX']}TOPIC_VIEWS
(TOPIC_ID)
values
( ? )
"
;
$dbh -> do_placeholder_query($query,array($main_topic_id),__LINE__,__FILE__);
$_SESSION['current_topic'] = $main_topic_id;
// }




/scripts/showflat.inc.php

PHP Code
 if ($_SESSION['current_topic'] != $current) {
$query = "
insert into
{$config['TABLE_PREFIX']}TOPIC_VIEWS
(TOPIC_ID)
values
( ? )
"
;
$dbh -> do_placeholder_query($query,array($current),__LINE__,__FILE__);
$_SESSION['current_topic'] = $current;
}


Replace with:

PHP Code
//	if ($_SESSION['current_topic'] != $current) {
$query = "
insert into
{$config['TABLE_PREFIX']}TOPIC_VIEWS
(TOPIC_ID)
values
( ? )
"
;
$dbh -> do_placeholder_query($query,array($current),__LINE__,__FILE__);
$_SESSION['current_topic'] = $current;
// }

Posted By: blaaskaak Re: Topic Views Help - 09/18/2008 8:22 AM
Hm, I would skip that hack for viewthreaded.php... Every message you read is a click. I don't know if you disabled threaded view, but if you didn't, I would stick with the default behavior of the script.

Please mind that it will still cache the view counter, it won't be updated until a post is made.

edit: I just saw the thread on ubbcentral, and it's the same as Rick suggested there. Don't know why it would stop with counting all together, I've tested it, and it works.
Posted By: FREAK1 Re: Topic Views Help - 09/19/2008 1:29 AM
blaaskaak thanks, I haven't done anything yet. I have to find where these items are located to make the changes.

Just so I am perfectly clear, am I still doing both of them or just one. If one, is it the top or the bottom one.

Please advise as I am going to attempt to do this tomorrow evening if I can find what you are telling me to change.

Thanks again for all of your help.
Posted By: blaaskaak Re: Topic Views Help - 09/19/2008 8:46 AM
/yourforum/scripts/showthreads.inc.php

that's the one you want to change. But it is the same change Rick asked you to do.
Posted By: FREAK1 Re: Topic Views Help - 09/20/2008 12:09 AM
Ok now I am lost !!! So now do none of them?
Posted By: blaaskaak Re: Topic Views Help - 09/20/2008 12:18 PM
well, do the one for showflat.inc.php
Posted By: FREAK1 Re: Topic Views Help - 09/22/2008 3:04 AM
I did the top one.. Seems to have worked because the views are up. smile
© UBB.Developers