Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old articles always on top #30

Open
Megafry opened this issue Jan 22, 2024 · 1 comment
Open

Old articles always on top #30

Megafry opened this issue Jan 22, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Megafry
Copy link

Megafry commented Jan 22, 2024

My customer had the following feedback regarding the plugin:

New articles cannot appear on the list of most viewed because of the high view count older articles already have.
Therefore the plugins should add the option to make older articles less relevant over time.

One easy solution is to divide the view count by the age of the article.

ex:
Article 1: 1689 views, 3 days old ➝ 563pt
Article 2: 23576 views, 308 days old ➝ 76pt
Article 3: 18232 views, 419 days old ➝ 43pt

Or by months to only decrease the point from article order then 2 Months.
Article 1: 1689 views, 0 months ➝ 1689pt
Article 2: 23576 views, 3 months ➝ 7858pt
Article 3: 18232 views, 13 months ➝ 1402pt
Article 4: 501 views, 1 months ➝ 501pt

Would such an addition be possible?

best regards

@lindseydiloreto
Copy link
Contributor

lindseydiloreto commented Jan 24, 2024

Thanks for the feedback, that's an interesting suggestion!

We have long-term plans which would make it easier to factor in the date of each view. No ETA, unfortunately.

In the meantime, you may be able to take advantage of unique keys to help break views into more distinct groups.

{# Generate unique key for this week #}
{% set thisWeek = now|date('W-Y') %}

{# Increment weekly counter #}
{% do craft.viewCount.increment(entry.id, thisWeek) %}

Hope that helps! We can leave this issue open for reference until a better long-term system is implemented.

@lindseydiloreto lindseydiloreto added the enhancement New feature or request label Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants