Forums / Setup & design / What is your approach to rank Most Popular in eZP?

What is your approach to rank Most Popular in eZP?

Author Message

Jacobi Jacobi

Sunday 01 August 2010 1:59:28 am

Hey, just want to get some ideas about what is your approach to rank Most Popular in eZP?

Obvious to me it is not smart idea to rank Most Popular by reading Apache log.

Gabriel Finkelstein

Sunday 01 August 2010 10:49:15 am

There's a cronjob that reads Apache logs and updates the view_count value. More info here:

http://ez.no/doc/ez_publish/technical_manual/4_x/features/cronjobs/the_cronjob_scripts#updateviewcount
http://ez.no/doc/ez_publish/technical_manual/4_x/reference/modules/content/fetch_functions/view_top_list

Or you can make a custom extension with an increment_view_count operator that receives an object id and increments the view_count value, and put it on the full view template.
And if you want to rank the most popular in the past X days, then you'll have to create a new table with columns contentobject_id, view_count, and date. The increment_view_count would increment the view_count column or insert a new row (if it's the first hit of the day) and you'll have to create a fetch function or an extended attribute filter that fetches the most viewed objects in the past X days.

http://ez.no/ezpublish/documentation/development/extensions/template_operator
http://ezpedia.org/en/ez/custom_fetch
http://projects.ez.no/types/ez_publish/extended_attribute_filter