1 personman Nov 28, 2005 20:29
3 blueyed Nov 28, 2005 20:58
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"?
4 personman Nov 28, 2005 21:06
That sounds fine to me.
5 blueyed Nov 28, 2005 22:08
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.
6 personman Nov 28, 2005 22:11
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.
7 blueyed Dec 05, 2005 21:48
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.
8 balupton Dec 06, 2005 15:27
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?
9 blueyed Dec 06, 2005 19:50
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..
10 balupton Dec 07, 2005 02:54
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?
11 personman Dec 07, 2005 03:03
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).
12 balupton Dec 07, 2005 03:12
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.
13 edb Dec 07, 2005 14:37
I'm curious about visits to single pages from search engines. Increments the page views?
14 blueyed Dec 08, 2005 00:02
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().
15 edb Dec 08, 2005 01:08
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...
16 yabba Dec 08, 2005 01:14
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?
¥
17 edb Dec 08, 2005 01:34
¥åßßå 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...
18 blueyed Dec 08, 2005 19:08
$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'
19 balupton Dec 08, 2005 19:23
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.
20 blueyed Dec 08, 2005 19:59
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.
21 balupton Dec 08, 2005 20:28
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);
???
22 blueyed Dec 08, 2005 20:40
Yep..
$Item = & $ItemCache->get_by_ID( $id );
Please see _main.inc.php for how to instantiate $ItemCache.
23 balupton Dec 08, 2005 20:44
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.