Open seandelaney opened 7 months ago
Great question. Unfortunately, your options may be a bit limited here.
The way to sort by most viewed typically looks more like this...
{% set partsQuery = craft.entries
.section('partsEntry')
.limit(12)
.with(['partImage', 'partBrand', 'partCategory'])
%}
{% do craft.viewCount.sort(partsQuery, 'viewedPartEntry') %}
However, that directly conflicts with the orderBy
parameter. Only one of those two sort methods can be applied at a time.
Perhaps you could give your users the option to change the sort order?
Long-term, we have plans to improve queries so that what you're looking for would be possible. No ETA on that, but I'll leave this ticket open in the meantime.
I'm counting views for entries. That all works fine.
My query is
My priorities for ordering:
I have set my key to be
viewedPartEntry
. I have added a Field calledpartTotalViews
and added to Part section entry type.If I try adding
orderBy('partTotalViews DESC, priorityOrder ...'
, I get errorColumn not found: 1054 Unknown column 'partTotalViews' in 'order clause'
How can I use your plugin to order by total views too?