I am writing a plugin that has some part tha shows how many times an entry is viewed.

However, I wouldn't know the track_view instance in advance.

I tried looking at the documentation but there is no indication which is the default.

What is the default track view instance?


The default is not to track at all. It is purely reliant on the track_view parameter.

If your plugin always resides inside channel:entries tag, you could attempt to access the TMPL class itself and see if you can access the parameters used for the channel:entries (which will define which track_view is used). Alternatively package the plugin with an extension which hooks into the channel entries to get the parameter - but bit overkill.

Otherwise you could pass the entry_id to the plugin and then read the database to see which track_view has a number and assume that (although not 100% reliable as they may use multiple track_views for different purposes).

  • Barring plugins for a moment, if I use {exp:channel:entries} tag, there is no way to determine if views are tracked or not inside that tag then? – developarvin Oct 10 '13 at 6:07
  • Nope. track_views is a parameter that the channel class acts upon when processing and increments the view count. channel:entries provides the variables for displaying the view counts (e.g. {view_count_one}) - but won't tell you which should be used out of the 4 tracking variables. Look at devot-ee.com/add-ons/simple-tracker which does what you want, but again you as the developer have to define which track variable to display. – Peter Lewis Oct 10 '13 at 8:44
  • Ok, that explanation is very helpful. – developarvin Oct 10 '13 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.