Recent Topics

1 May 20, 2004 20:04    

Removed - See the post below with the outcome.

2 May 21, 2004 17:48

I've completed the changes to display the number of views a post has received. You can view the out come on my blog [url=http://www.jeffbearer.com]http://www.jeffbearer.com[/url].

Here are the patch files for the modifications I made:

Download: [url=http://www.jeffbearer.com/stuff/num_views.tar.gz]num_views.tar.gz[/url] (1667 bytes)

Here is the content of the README file

Modifications made to b2evolition 0.9.0.3 to add a view counter to the posts table, to display the number of views next to the word count, and to increment the views when a story is viewed individually.

Descriptions of the changes made in the patches.

[u]_blog_main.patch[/u]
Added a condition where if the $more parameter is set the function addview() is called and the post_views field for the post is incremented in the evo_posts table.
The value of $MainList->result_rows[0]->ID is incremented so the display is accurate.

[u]_class_item.patch[/u]
Added the function Item::views() which displays the number of views for the item. The supporting $views variable for the object is added as well.

[u]_class_itemlist.patch[/u]
Added the post_views field to the query and to the object.

[u]_functions_bposts.patch[/u]
Added the function addview() which increments the post_views field in the evo_posts table.
Added the post_views field to the queries for the functions get_postdata, Item_get_by_ID and Item_get_by_Title.

[u]basic._main.patch[/u]
Added the call to display the views to the _main template of the basic skin.

[u]evo_posts.sql[/u]
SQL query to add the post_views field to the evo_posts table.

ToDo
A language variable should replace the hard coded ?view? in the basic/_main.php file.

Please consider this for addition into the official b2evolution.

3 May 21, 2004 18:28

That's a cool feature, Jeff, thanks. It almost made me choose GeekLog last year instead of b2evo. Even if it doesn't get integrated, I'll probably use your hack on my site eventually.

And I'm impressed! You've been using b2evolution for what, a week now? And you're already writing hacks for it? Nicely done, guy!

I've got a few questions, though, maybe you already know about these...

1. I think that incrementing the views really should go in the log_hit function. There's already a lot of things going on in that function to prevent it from logging the same person over and over again, keep spiders from registering as a visitor hit, etc. I'm not familiar enough with the function to give you more direction, though. Maybe one of the other guys could help you more on that. (I say that because I just hit refresh on your page a few times, and saw that the number keeps going up, even though it's not truly another "view" if it's the same person in the same session. Left a comment, and it went up two more times. So, you might want to subtract 5 from the view amount on post #157. Sorry about that.)

2. The language variable is easy. Replace

Views:

with

<?php echo T_('Views:'); ?>

3. Anyone who wants this should go to http://jeffbearer.com/index.php?title=title&more=1&c=1&tb=1&pb=1

Nice site, Jeff. Keep the hacks comin! :)

4 May 21, 2004 18:39

Thanks for the compliments and the tips.

I'm not going to make any changes now as I don't want there to be any version confusion before this gets into CVS. If they don't decide to use the hack then I'll put out another version with some of those improvements.

Also as for the same person bumping up the number, that's the way geeklog works so I never thought of restricting it. It's a good idea and I'll look into it when I do update it.

5 May 21, 2004 19:01

nice feature. I'll integrate it into CVS though I have not looked into it yet..

Thanks.. :D

6 May 22, 2004 18:08

I added it already locally, but the incremention of views should happen through a renderer plugin. That makes sense because you could view several "more"-posts at once or even decide not to count views on several posts etc.

Unfortunately the plugin system is not developed enough to handle this, because
a) the plugin should be called when the Item object gets created, not when content is displayed (because $Item->views() can be called before ->content())
b) we need the post ID and "more" status in the renderer (or whatever it will get) function.

This will make it into 0.9.1, but I need Francois' feedback / enhancements on this..

on with the hacks.. B)

btw: isaac wrote

log_hit(-) [...] There's already a lot of things going on in that function to prevent it from logging the same person over and over again

That's not true. You'll see that when you press F5 on a blog page it will make it into your hitlogs table again and again (if it makes it into it at all).
I changed that so we have now a default reloadpage_timeout of 300 seconds, so when the same IP && user_agent request the same URI in this time it will not make it into the hitlog anymore. This will be in 0.9.1, too.

7 May 24, 2004 15:57

blueyed wrote:

This will make it into 0.9.1, but I need Francois' feedback / enhancements on this..

Great! Of course I'm happy for my own selfish reasons, so I don't have to patch my blog every time I upgrade. :)

The plugin is a good idea, My personal opinion is that it doesn't need to be that flexible. I think all or none (by editing the skin) would be enough functionality.

I did try to count the view before the record was received was loaded, but ran into the problem where the ID isn't always used. I figured it was best for a newbie like me not to go messing with that sql logic as it had a lot of different bits and I don't have a full picture of all the software yet.

8 Feb 11, 2005 11:44

hey can you make simmilar plugin for links ?

I have a blog www.rojbash.net , we are a group that post intresting links everyday ...

the title is the link .

can you make something to count the clicks on the link ?

and another suggestion , can we have the some most viewed (in this case *Clicked*) posts in the side bar?


Form is loading...