1

Topic: Omit view count

Is there a way to omit view count update from the administrator and own topics?

forum, Art, Architecture

Did you visit the textpattern forum?

2

Re: Omit view count

anyone?

forum, Art, Architecture

Did you visit the textpattern forum?

Re: Omit view count

I'm not great with PHP/SQL and I haven't tested this code, so be warned that this might not work.

Anyway, open viewtopic.php and find

if (!$pun_user['is_guest'])
        $result = $db->query('SELECT f.no_images, t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, s.user_id AS is_subscribed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].') LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());

replace with

if (!$pun_user['is_guest'])
        $result = $db->query('SELECT f.no_images, t.subject, t.closed, t.num_replies, t.sticky, t.poster, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, s.user_id AS is_subscribed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].') LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());

find

// Increment "num_views" for topic
$low_prio = ($db_type == 'mysql') ? 'LOW_PRIORITY ' : '';
$db->query('UPDATE '.$low_prio.$db->prefix.'topics SET num_views=num_views+1 WHERE id='.$id) or error('Unable to update topic', __FILE__, __LINE__, $db->error());

replace with

// Increment "num_views" for topic
if (pun_user['g_id'] != PUN_ADMIN AND  (isset($cur_topic['poster']) AND $pun_user['username'] != $cur_topic['poster']))
{
    $low_prio = ($db_type == 'mysql') ? 'LOW_PRIORITY ' : '';
    $db->query('UPDATE '.$low_prio.$db->prefix.'topics SET num_views=num_views+1 WHERE id='.$id) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
}
Looking for a certain modification for your forum? Please take a look here before posting.