I’m currently setting up my blog, and I want to create a sidebar with a “Popular Posts” area. How do I sort blog post with the most views (or any other related metric)?
How do you measure page views? Or is that what you want to know?
Edit: Check out this post for a simple visitor stats solution: Stats plugin / Hit counter
There’s also a Piwik plugin, which might be useful to get the data.
(I don’t know if any of these is still actively developed)
How would I sort posts based on Popularity?
It’s not the how but rather the what here… What is popularity to you? How do you define it? How do you measure it? Do you have any clues which posts are popular and which are not?
Popularity is often used on ecommerce websites as a metric that encompasses a whole diversity of other metrics: page views (overall, over the last X days, compared views increase), conversions, ratings, returning customers, etc
What do you want to do? Because to answer your question one could say “use the sortBy function with your popularity metric”
I’ll just sums it up…
Ways to measure popularity:
- Returning visits
- User ratings
Solutions to measure popularity:
- Google Analytics
- Other external solution
- Kirby plugin (if exists)
- Own PHP, Ajax with cookies or local storage
Like already said, you also need to think of what time period it should measure. 1 year, 1 month, 1 day or no time limit?
Just to be clear, Kirby itself doesn’t count views or measure “popularity” of any kind. You need a third-party tool (analytics, plugin…) that does this counting, then get this information back in your templates (or controllers).