Posted At : Apr 28, 2008 18:00 PM
| Posted By : Ed Tabara
Related Categories:
ColdFusion,
1ssBlogThis weekend when reading some WordPress blog i noticed that there was used some kind of entry popularity meter. Happens that there exist a special WordPress plugin for that.
And i thought "Wow! That's nice and i think many ColdFusion bloggers would like to have something similar.".
First i tried to find something similar in ColdFusion, but without any luck of course. Then i tried to find the description of the algorythm used, but again no luck.
So, my next thought was.. what a heck! why not just create something similar? :) This said, after few minutes of thinking and a couple of other minutes writting the code (thanks to ColdFusion ;)), i am ready to present what i came to.
NOTE:This is just a prove of concept, so if anyone have ideas how to have it better, please share your thoughts.
Ok. First of all the idea.
As most popular, 100% popularity, is taken the entry with the biggest number of views. The popularity for all other entries is calculated in comparison with the most popular one. So, if the most popular entry have 100 views and other entry have 23 views, the last one will be considered to have 23% popularity.
Same is done based on comments number (100% popularity will have the entry with highest number of comments).
So... the result, for each entry, will look something like: 61% / 36% Popularity. Where 61% is the popularity based on the number of views and 36% is the popularity based on the number of comments.
And now the code based on 1ssBlog.
The following function will return a structure with 2 keys: one with the number of views for the most visited entry and other with the number of comments for the entry with most comments.
Select Max(views) as maxView, Max(commentsNumb) as maxComments
From onessBlog_entries
Where is_active = 1
and posted <= GetDate()
And now the usage.
#Round(100*Val(viewsNumb)/viewsComments.views)#% / #Round(100*Val(commentsNumb)/viewsComments.comments)#% Popularity
NOTE:The popularity meter will be included in the next 1ssBlog updater.
Please don't hesitate to comment.
Comments (3)|
Print|
Send
| 1340 Views
| 13% / 21% Popularity