2 blueyed Nov 28, 2005 20:42

I'd like to keep views() as it is now though (not just because of "backward" compatibility).
Do you think views_phrase() would be as good? Is there a better phrase as "phrase"?
That sounds fine to me.
Implemented in CVS HEAD.
Thanks for the suggestion.. :)
I've also made the custom skin and the backoffice use this instead of the "old" views() method.
Great. I'll watch future releases and when I see it in the custom skin I'll start using it in my skins, too. Thanks a lot, Daniel.
After feedback from François I'll break backward compatibility with Phoenix-Alpha here.
I've changed Item::views() so that it takes params for $zero, $one and $more now like other functions do. Those default to 'No views', '1 view' and '%d views'.
So skins should be changed to use $Item->views(), but not output T_('views') after that.
Sorry, but it is more consistent with the rest of the template functions and is easier on the skins anyway.
Whats wrong with the good ol' "0 View(s)", "1 View(s)", "1111 View(s)" ;)
And when does the actual hit of the post occur?
A hit occurs if you view the full post. Reloads will be detected and not counted.
using "x view(s)" is not so nice IMHO and fails for languages, where you have different forms for 0, 1 and more. Actually, there are even languages with more complex plural forms..
Good point about the view(s) thing.
So the actual hit occurs when the item is loaded into an itemlist, or when the item is loaded from the itemlist, or when the item is accessed?
A hit is logged for the post when you view the post by itself by going to the permalink or the comments section for that post. It doesn't count page loads that show more than one post (like your front page).
Hmmmm.....
So the hit occurs when the post is the only one being displayed.
So when the view or mode or wotever it is is 'single'?
Coz that could be a problem.
Because my skin displays the comments and trackbacks as the same page that lists all the other posts.
So:
[Post Header]
[Trackbacks]
[Comments]
[Contents]
(Then goes on to next post)
Is there a way to pump the hit up manually, so like for my skin i could make it so when they click the button to view the contents of the post the hit occurs.
I'm curious about visits to single pages from search engines. Increments the page views?
Good point, EdB. I'll add an "$Hit->agent_type != 'robot'" to the check before incrementing the view.
balupton, you can increment the view manually like this:
$Item->set_param( 'views', 'number', $this->views+1 );
$Item->dbupdate(); // move to end of method, if we should have more params to be changed someday
This is copied from Item::content().
blueyed wrote:
Good point, EdB. I'll add an "$Hit->agent_type != 'robot'" to the check before incrementing the view.
It's possible I misunderstand what "$Hit->agent_type != 'robot'" will do, but I'm thinking it will mean "if the visitor is from a search engine then don't increment the views counter". Personally I think search engine traffic should count as page views, though sometimes the visitor got there because of a few random words on the whole page matching up.
Pre-phoenix there were two different hacks that served this purpose. One required clicking on the permalink. I tried it but realized it meant a post entirely on the multi-post page didn't count, nor did a visit from an SE even if the search string was very focused (implying the visitor stayed). I built a hack that required the visitor to be on a single post page (where post_ID had a value) knowing that it meant if I wanted to get my counter to increment I had to use a "read more", but comfortable knowing search engine traffic counted.
Hard place to be eh? What *exactly* counts as a page view? 3 seconds then I go away: is it a countable view or not? Hmmm...
Hard place to be eh? What *exactly* counts as a page view? 3 seconds then I go away: is it a countable view or not? Hmmm...
Does the fact that your page is open in my browser for ten minutes whilst I make a brew, then come back and close it, mean I've read as much as the three second viewer?
¥
¥åßßå wrote:
Does the fact that your page is open in my browser for ten minutes whilst I make a brew, then come back and close it, mean I've read as much as the three second viewer?
In your case: YES cuz you're always whipping up a fresh batch ;)
Seriously: that's where the problem lies in counting page views. What would be the rule to determine if a visitor is actually viewing your page or just randomly surfing (and ignoring)? I suppose one could add a link that says "I read this page" and count that, but then you're betting that visitors will bother to click the link. There's no easy answer to it. The way I felt was that visitors from search engines tended to be people who were looking for something your post offered, so I wanted to count them as page views.
Way back in the day I had a hack post that used words normally associated with 'adult oriented' content in the title. I had so many visitors to that page who were searching for a particular keyword (biga**) that I finally changed the title of the post. I guess no matter how one tracks hits there'll be conditions and expectations, and it'll eventually miss valid visitors and count invalid ones. Good thing I'm not a developer! If I was I'd feel obligated to care about more people than just me!
I'm going flying! I hope it snows. Always wanted to fly in and through and over fresh snow...
$Hit->agent_type != 'robot'
means it's not a search engine indexing.
It's different than a user coming from a list of search results.
A user should have $Hit->agent_type == 'browser'
So is there a way to increment the view count through a function, because my skin for my blog users can post comments without viewing the post by itself, so people never need to view the post byitself which means the view count will never go up :(
So for me it would be very usefull to do this.
balupton, you can use the code I've posted above (the two lines).
We could make a method for the Item class out of it, but it would just make it a one-liner instead of a two-liner for you.
Think about it anyway. Having the view of items increased when displaying them in a list is not that good IMHO.
sorry never saw your post.
The way i'll do it for my skin is have a javascript function called when they view the post's comments/contents/trackbacks.
So if they view the comments it will call a javascript function that sends a request to the php page: increment.php?postid=X
Or something like that.
It will only do the increment once, so if the user click trackbacks and contents only one increment will occur.
So is there a way that i could do:
$Item = new Item($PostId);
???
Yep..
$Item = & $ItemCache->get_by_ID( $id );
Please see _main.inc.php for how to instantiate $ItemCache.
Alrite thanks for that, all the times i've looked there was just, get_by_row
So everybodys happy ;)
Good idea, IMHO.
I'll add it.