Collecting view-count from catalogue entry

Post

Posted
Rating:
#5060 (In Topic #1135)
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Firstly, I used PARAM_INFO to debug the view counter of a catalogue entry – each time I refreshed the page, {VIEWS} within the param_info table increased as normal. However, if I reference the param within the template, it doesn't update. It updates after clearing the caches though – so is there a way to get a live count (no caching) when the template references {VIEWS}?

Secondly, I tried replacing {VIEWS} with {$VIEWS,catalogue_entries,ce_views,{ID}} to see if it would give me a live count. It did not – but I noticed that {VIEWS} always seems to be +1 of whatever {$VIEWS} outputs. I investigated by putting both {VIEWS} and {$VIEWS} right next to each other, and {VIEWS} always outputted 1 higher. I imagine they should be the same?

Thirdly, it seems that the view counter of each catalogue entry only increases if the entry is viewed from within the catalogues module directly and will not increase if the entry is being viewed from a secondary location (such as a Comcode page using the cc_embed block). Is this normal or a bug?

Last edit: by Joe

Online now: No Back to the top

Post

Posted
Rating:
#5068
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
each time I refreshed the page, {VIEWS} within the param_info table increased as normal. However, if I reference the param within the template, it doesn't update

Is "the template" CATALOGUE_DEFAULT_ENTRY_SCREEN? I can't reproduce an issue with that. If you're actually talking about a category view, this probably is coming from a block (which are used behind the scenes) and block caching would cause the issues. We're not using VIEWS in any catalogue block template by default so this is undocumented behaviour of something undocumented, and not really fixable.

However, using the VIEWS symbol instead is a very good workaround. Because it is a symbol that is dynamic regardless of caching. It not working for you is strange, all I can think is if you're editing the template of a block that you've placed with the quick_cache block option – which will make Tempcode compile statically into the cache.

always seems to be +1 of whatever

That's a small bug, fixed in https://github.com/ocproducts/composr/commit/757720868000bbc937ef81bee2fbc3228b7fe268

Thirdly, it seems that the view counter of each catalogue entry only increases if the entry is viewed from within the catalogues module directly and will not increase if the entry is being viewed from a secondary location

This is normal. View counts are only incremented when viewing entry screens, i.e. when the entry is viewed individually.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Forum statistics:
  • 2,052 topics, 7,195 posts, 10,830 members
  • Our newest member is Customcollective
Back to Top