Recent Topics

1 Feb 16, 2006 10:49    

[u]Version: 1.6 Phoenix Alpha[/u]
I'm trying to prevent my own view from being added to its total view count. I've tried going into _item.class.php and I think a logic can be added somewhere before

if( $dispmore && !$preview && $Hit->is_new_view() )

Basically, a simple check on 'current_user ID' vs 'author ID' of that specific post. Any help would be much appreciated... I've spent more than 20hours trying to get the right code :'( (I guessed that's the price to pay for a newbie)

2 Feb 16, 2006 16:03

Give this a try. Make the change in the skin. Go to the bottom and find

$Hit->log();        // log the hit on this page


and change it to

if ( $theauthor != $current_User->get( 'login' )  ) $Hit->log();        // log the hit on this page


Then, find this part

$Item->Author->preferred_name();


and add a line below it:

$Item->Author->preferred_name();
$theauthor = $Item->Author->get( 'login');

3 Feb 16, 2006 18:13

First & foremost, thank you very much for your help.

The $theauthor != $current_User->get( 'login' ) correctly verify the condition and it did stop $hit from executing. However, the view count continues to increase.

I guessed $Hit->is_new_view() could still have been executed, it just didn't get logged into db. Hence, if( $dispmore && !$preview && $Hit->is_new_view() ) remains true.

I tried inserting $theauthor != $current_User->get( 'login' ) into _item.class.php but received a 'non-object' error instead. I was thinking if I can get $theauthor value into _item.class.php, your solution might work there... your advice pls.

4 Feb 16, 2006 18:44

Try :-
if ( isset( $current_User ) and $Item->Author->get( 'login') == $current_User->get( 'login' ) ) $Item->set( 'views', $Item->views - 1);
$Item->content();

¥

5 Feb 16, 2006 22:06

It works! It finally works!! This community truly rocks!!! Thank you both for your help. I do hope the beta/final release will take this into consideration since there's no reason why the author would want to increase his own view count. I just wanna say 'Thank you' once again. Cheers! :p


Form is loading...