View Full Version : Preventing thread authors from increasing the view count of their own threads
I searched but couldn't find anything related here or on vbulletin.com forums.
I've decided to post here instead of possibly wasting time and be told this would require hacking and getting pointed here.
Preventing the thread view count from getting increased by the thread's starter is very useful, and I'd say fundamental to any forum. I was able to find simple mods for several other forum solutions, but not for vBulletin.
If anyone knows how to achieve this, I'd appreciate directions.
Thank you.
tnguy3n
04-10-2005, 08:10 PM
I didn't test it out, but you can try to replace
$DB_site->shutdown_query("
UPDATE " . TABLE_PREFIX . "thread
SET views = views + 1
WHERE threadid = " . intval($threadinfo['threadid'])
);
WITH:
$DB_site->shutdown_query("
UPDATE " . TABLE_PREFIX . "thread
SET views = views + 1
WHERE threadid = " . intval($threadinfo['threadid'])
AND postuserid <> $bbuserinfo[userid]
);
Paul M
04-10-2005, 08:23 PM
It might help if you said which file this was in ;)
Thank you tnguy3n! This addition to showthread.php seems to work fine.
edit: nope, jump 2 posts ;)
Marco van Herwaarden
04-10-2005, 08:33 PM
Maybe better to try to avoid the query to be run (would save a query again) by surrounding it with an if tgesting for authorid. Something like:
if ($threadinfo['postuserid'] != $bbuserinfo['userid'])
{
run query
}
sorry, i was wrong. in fact, it's not working properly, view count is not increased by anyone.
(i enabled instant view updating in cp)
edited: post=view*
I released a hack for this for VB2. Feel free to look at that for reference.
Since I have little knowledge of PHP and how the forum's script works (plus I do need guest views to count), I hope someone could create this type of solution for vBulletin 3.
I'm surprised that it's not a widely requested feature. It's quite popular with other forums.
Marco van Herwaarden
04-11-2005, 01:30 PM
Since I have little knowledge of PHP and how the forum's script works (plus I do need guest views to count), I hope someone could create this type of solution for vBulletin 3.
I'm surprised that it's not a widely requested feature. It's quite popular with other forums.Well it really should work. Try the following edit to your showthread.php:
Find:
if ($vboptions['threadviewslive'])
{
// doing it as they happen
$DB_site->shutdown_query("
UPDATE " . TABLE_PREFIX . "thread
SET views = views + 1
WHERE threadid = " . intval($threadinfo['threadid'])
);
}
else
{
// or doing it once an hour
$DB_site->shutdown_query("
INSERT INTO " . TABLE_PREFIX . "threadviews (threadid)
VALUES (" . intval($threadinfo['threadid']) . ')'
);
}
And replace by:// Ignore views by thread starter
if ($threadinfo[postuserid] != $bbuserinfo[userid])
{
if ($vboptions['threadviewslive'])
{
// doing it as they happen
$DB_site->shutdown_query("
UPDATE " . TABLE_PREFIX . "thread
SET views = views + 1
WHERE threadid = " . intval($threadinfo['threadid'])
);
}
else
{
// or doing it once an hour
$DB_site->shutdown_query("
INSERT INTO " . TABLE_PREFIX . "threadviews (threadid)
VALUES (" . intval($threadinfo['threadid']) . ')'
);
}
}
// End: Ignore views by thread starter
MarcoH64: Yes, this (really) works properly. Thanks!
However, queries jumped from 8 to 13.
Can someone modify it to be more query friendly? :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.