Giter VIP home page Giter VIP logo

craft-entry-count's Introduction

Stable Version Total Downloads

Entry Count Plugin for Craft CMS

The Entry Count Plugin was built specifically for the Craft Plugin Development video course by Mijingo, which has since been discontinued. The Getting Started with Craft Plugin Development course on CraftQuest is a good alternative.

It allows you to count and display the number of times an entry has been viewed in Craft CMS. The plugin is intended for educational purposes and can be freely used for simple use-cases. For anything more complex, use the View Count plugin.

Documentation

Learn more and read the documentation at putyourlightson.com/plugins/entry-count »

License

This plugin is licensed for free under the MIT License.

Requirements

This plugin requires Craft CMS 3.0.0 or later, or 4.0.0 or later, or 5.0.0 or later.

Installation

To install the plugin, search for “Entry Count” in the Craft Plugin Store, or install manually using composer.

composer require putyourlightson/craft-entry-count

Created by PutYourLightsOn.

craft-entry-count's People

Contributors

bar9 avatar bencroker avatar peet86 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

craft-entry-count's Issues

How to get top 5 posts based on count?

I am not that familiar with twig and craft, is it possible to get top 5 posts based on count? As far as I understand the count is in another table and i can not simply do
{% set entries = craft.entries({ section:'instaBlog', limit:3, offset: 0, order: "count desc" })%}

How to access getCount function in Elements API

I want to get the entry count in my json feed which is generated by Elements API. So I tried this:

use putyourlightson\entrycount\EntryCount;
$views = EntryCount::$plugin->getCount($entry->id);

But then I get:

{
    "error": {
        "code": 0,
        "message": "Calling unknown method: putyourlightson\\entrycount\\EntryCount::getCount()"
    }
}

Any help is appreciated, thanks!

How can I add a entry count if entries don’t have URLs?

I have an entry structure that I'd like to get an entry count on.
They are all living on a page as a list.
When someone clicks on a list item, it doesn't go to the entry url, it goes to a document asset link in a new tab, I'd like to be able to add an entry count when the users clicks on a list item.

Is this something that is possible to do with this plugin in a link <a> tag?

Slow down the Page massiv

Any Idea about this Topic? When the Plugin is activated the loadtime is +2-3 seconds as if the plugin is disabled? :/ I've it on my Homepage for 30 posts they all get a +1 after each reload. Are this to much posts?

How to stop fake increments on entry

I am trying to find a way that stops fake entry counts from users just refreshing the page or visiting it multiple times on multiple machines.

What is the best way to not have the count increment on every page/entry refresh?
Is there some logic that can wrap around the increment call that checks for logged-in and not logged-in users making requests to the page?

Plugin produces no results

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 %}

Better support for multi-site setups

My website is running in five languages. Your plugin counts every entry view (in any language/site) for each entry variation in each site. When I want to sort my entries on view count (which I suppose your plugin is mainly intended for), I should be able to get only the entries for my current site. This can be achieved by changing line 80 of EntryCountService.php to ->site(Craft::$app->getSites()->currentSite) (instead of '*' as argument to the function). This is also more in line with your control panel view: it counts every view as a view for each site, but displays all sites (so I now have 5 identical lines on my control panel view of your plugin). I will create a pull request for this fix when I have more time later, if you don't find the time to implement this fix yourself.

CP only shows enabled entries

The CP only shows enabled entries. How about an option to also show disabled entries, or just all entries that have an entry count > 0?

How can I exclude one or more entries from the entries output?

I am wanting to exclude one or more entries (by their entry ID) from the entries output. The output would be displaying a limited number of the most viewed entries (e.g. 6) but there may be cases where certain entries shouldn't be displayed and therefore would need to be excluded. Is this possible?

New to Craft - Where Do

So sorry for being the noob here but as the title say, I'm pretty new to craft and i'm having a bit of trouble implementing this. I have a structure with over 100 entries and I'm trying to implement this on the template that list those entries. So each entry will have a count next to it.

Does the code go inside the loop, outside the loop, or the template that each entry links to ?

I already have this in my code
{% set entries = craft.entries.section('drinks').orderBy('lft desc') %}

No entries counted

I have followed the installation/ templating instructions but yet in the dashboard and on the entry pages, but they aren't being counted and the dashboard still says "No entries counted". Any guidance would be appreciated.

syntax error, unexpected 'return' (T_RETURN)

I have this error after finished the "Template Variables" video on Mijingo.

.../craft-cms-plugin-dev/craft/plugins/entrycount/variables/EntryCountVariable.php(28)
 public function getCount($entryId)
17     {
18         return craft()->entryCount->getCount($entryId);
19     }
20 
21     /**
22      * Returns counted entries
23      *
24      * @return ElementCriteriaModel
25      */
26     public function getEntries()
27     {
28         return craft()->entryCount->getEntries();
29     }
30 
31     /**
32      * Increment count
33      *
34      * @param int $entryId
35      */
36     public function increment($entryId)
37     {
38         craft()->entryCount->increment($entryId);
39     }

I tried to copy and paste your code into the file but it did not go away.

Craft CMS 2.6.2973

No results in control panel?

I assume I'm supposed to see a summary of entries and counts in the Entry Count cp area - but I just see "No entries counted".

I am incrementing counts - and have confirmed that from the front end via Twig (ie. {{ craft.entryCount.count(entry.id) }} but none of that is reflected in the CP.

Craft 3.4.4
MySQL 5.7.26
PHP 7.3.8
Entry Count 2.0.2

$dateCreated must not be accessed before initialization

Facing the issue after updating to the latest craft version

Error: Typed property putyourlightson\entrycount\models\EntryCountModel::$dateCreated must not be accessed before initialization

Craftcms Version: 4.3.1

I initialized the dateCreated and dateUpdated value in the models and it works.

Entry Count with the {% paginate %} tag

Is there a way to use the plugin with the {% paginate %} tag? So something like this

{% paginate craft.entryCount.entries.all() as pageInfo, entries %}

I tried this tag, but got this error

Argument 1 passed to craft\helpers\Template::paginateCriteria() must implement interface craft\elements\db\ElementQueryInterface, array given

Not counting

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

Craft CMS 4

Hi, just checking if this will be compatible with Craft CMS 4?

I see there is a recent push that was called "Craft 4 version" but when I look at my site on the Craft 4 Update tab, I still see that this plugin has the status of "NOT READY".
Screen Shot 2022-06-21 at 4 12 13 PM

Thanks!

Daily count?

Any plans to add in a daily count for entries? A use case would be for having a most popular section of the last days entries.

I'm currently looking for something, and this plugin is the closest I've seen. If not, I'll try to extend your plugin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.