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

Plugin produces no results #21

Closed jacksoncool closed 5 years ago

jacksoncool commented 5 years ago

installed plugin via the store, and entries get counted (none listed in the admin). And no show up in templates.

I'm using the following template code:

{% set entries = craft.entryCount.entries.section('articles') .limit(4) .all() %}

                              {% for entry in entries %}
                                {% set count = craft.entryCount.count(entry.id)
                                 %}

                            <li>
                              <a href="{{ entry.url }}">{{ entry.title }}</a>
                            </li>
                            {% endfor %}
putyourlightson commented 5 years ago

Try this first to ensure that counts are being stored in the control panel:

{% set entry = craft.entries.one() %}

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

{{ craft.entryCount.count(entry.id) }}