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

How to access getCount function in Elements API #20

Closed arifje closed 5 years ago

arifje commented 5 years ago

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!

putyourlightson commented 5 years ago

Should be:

EntryCount::$plugin->entryCount->getCount($entry->id);
arifje commented 5 years ago

Awesome, thanks!