madebyraygun / trending-posts

Trending Posts for Craft CMS 3 tracks pageviews over time and orders posts by popularity on the front-end.
MIT License
6 stars 3 forks source link

Compatibility with Verbb Events and Ticket Types #17

Open engram-design opened 3 years ago

engram-design commented 3 years ago

Looks like there's an issue with this plugin and Events. When you load up Ticket Types to add to an event ticket, an error will be thrown:

{,…}
error: "An exception has been thrown during the rendering of a template ("Getting unknown property: verbb\events\elements\TicketType::views")."
exception: "Twig\Error\RuntimeError"
file: "vendor/craftcms/cms/src/templates/_elements/tableview/elements.html"
line: 27
trace: [{file: "vendor/twig/twig/src/Template.php", line: 378,…},…]

I'm not completely familiar with this plugin, but it's certainly related to how it attaches "views" information to every element. My suggestion might be to change:

https://github.com/madebyraygun/trending-posts/blob/9601b292290e61b5f3f402ad4b37589450bd257b/src/TrendingPosts.php#L121-L129

to change the binding class to be Entry::class (similar to the EVENT_SET_TABLE_ATTRIBUTE_HTML event), which would prevent this error. Again, I'm not sure if this plugin is for non-entries?

daltonrooney commented 3 years ago

Yeah, we should really only be firing the event on entries. I should be able to take care of this pretty quickly. 👍