putyourlightson / craft-entry-count

Counts and displays the number of times that an entry has been viewed in Craft CMS.
MIT License
47 stars 19 forks source link

Not counting #2

Closed mattaellis closed 8 years ago

mattaellis commented 8 years ago

I've just added Entry Count Plugin included the {% set count = craft.entryCount.count(entry.id) %} and {{ count }} tags on an entry template.

The plugin is enabled, however, the count is alway returning '0'. I've tried switching the 'Ignore logged in users' option and the IP field is blank.

Nothing is being written to the DB, either for old and newly created entries. Though, if I manually add a row to the craft_entrycount table, it displays correctly.

Is there something I've missed? I'm on Craft Pro 2.5.2767

putyourlightson commented 8 years ago

are you sure that the entry variable is valid in your template? try hard-coding in the entry id to test if it is writing to the database.

mattaellis commented 8 years ago

Yes. For this specific page, {{ entry.id }} outputs 436.

If I then try {% set count = craft.entryCount.count(436) %} I'm still getting 0 and nothing is being written to the DB.

putyourlightson commented 8 years ago

you'll need to increment the entry count for that entry id first...

{% do craft.entryCount.increment(entry.id) %}

mattaellis commented 8 years ago

Oh man! Sorry. Thanks Ben, that's what I was missing. Next time I'll RTFM :-0

putyourlightson commented 8 years ago

sure thing