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

Adding 'trackSection' to trending-posts.config fails to work #2

Closed adrienne closed 5 years ago

adrienne commented 5 years ago

When i have that in my config, and i go to a page with the {% do craft.trendingPosts.increment(entry.id) %} tag on it, i get the following Twig error:

image

Here's the full stacktrace:

yii\base\ErrorException: Undefined variable: getSection in /home/vagrant/code/vendor/madebyraygun/trending-posts/src/services/TrendingPostsService.php:66
Stack trace:
#0 /home/vagrant/code/vendor/madebyraygun/trending-posts/src/variables/TrendingPostsVariable.php(28): madebyraygun\trendingposts\services\TrendingPostsService->increment()
#1 /home/vagrant/code/vendor/twig/twig/lib/Twig/Extension/Core.php(1608): madebyraygun\trendingposts\variables\TrendingPostsVariable->increment()
#2 /home/vagrant/code/vendor/craftcms/cms/src/helpers/Template.php(73): ::twig_get_attribute()
#3 /home/vagrant/code/storage/runtime/compiled_templates/83/83596fbb158260e3d2f9299fa71f0b2263616f6c62b32f7e0a2ac6d0a70bf24f.php(57): craft\helpers\Template::attribute()
#4 /home/vagrant/code/vendor/twig/twig/lib/Twig/Template.php(189): __TwigTemplate_0094fc48bee2670bd62e7cd8bf24d8783b7878c5328858b06e9a3f958fb33f4a->block_content()
#5 /home/vagrant/code/storage/runtime/compiled_templates/32/32bd5d9c728e424f958ac3a863a793c6c190fa2b742553655605b23db9cc986c.php(127): __TwigTemplate_9cfe92b5526aea2cd2c28acfa97bd2d4aaa575d1a1bd572cc809b6f12c193f26->displayBlock()
#6 /home/vagrant/code/vendor/twig/twig/lib/Twig/Template.php(390): __TwigTemplate_9cfe92b5526aea2cd2c28acfa97bd2d4aaa575d1a1bd572cc809b6f12c193f26->doDisplay()
#7 /home/vagrant/code/vendor/craftcms/cms/src/web/twig/Template.php(49): __TwigTemplate_9cfe92b5526aea2cd2c28acfa97bd2d4aaa575d1a1bd572cc809b6f12c193f26->displayWithErrorHandling()
#8 /home/vagrant/code/vendor/twig/twig/lib/Twig/Template.php(367): __TwigTemplate_9cfe92b5526aea2cd2c28acfa97bd2d4aaa575d1a1bd572cc809b6f12c193f26->displayWithErrorHandling()
#9 /home/vagrant/code/vendor/craftcms/cms/src/web/twig/Template.php(31): __TwigTemplate_9cfe92b5526aea2cd2c28acfa97bd2d4aaa575d1a1bd572cc809b6f12c193f26->display()
#10 /home/vagrant/code/storage/runtime/compiled_templates/83/83596fbb158260e3d2f9299fa71f0b2263616f6c62b32f7e0a2ac6d0a70bf24f.php(47): __TwigTemplate_9cfe92b5526aea2cd2c28acfa97bd2d4aaa575d1a1bd572cc809b6f12c193f26->display()
#11 /home/vagrant/code/vendor/twig/twig/lib/Twig/Template.php(390): __TwigTemplate_0094fc48bee2670bd62e7cd8bf24d8783b7878c5328858b06e9a3f958fb33f4a->doDisplay()
#12 /home/vagrant/code/vendor/craftcms/cms/src/web/twig/Template.php(49): __TwigTemplate_0094fc48bee2670bd62e7cd8bf24d8783b7878c5328858b06e9a3f958fb33f4a->displayWithErrorHandling()
#13 /home/vagrant/code/vendor/twig/twig/lib/Twig/Template.php(367): __TwigTemplate_0094fc48bee2670bd62e7cd8bf24d8783b7878c5328858b06e9a3f958fb33f4a->displayWithErrorHandling()
#14 /home/vagrant/code/vendor/craftcms/cms/src/web/twig/Template.php(31): __TwigTemplate_0094fc48bee2670bd62e7cd8bf24d8783b7878c5328858b06e9a3f958fb33f4a->display()
#15 /home/vagrant/code/vendor/twig/twig/lib/Twig/Template.php(375): __TwigTemplate_0094fc48bee2670bd62e7cd8bf24d8783b7878c5328858b06e9a3f958fb33f4a->display()
#16 /home/vagrant/code/vendor/twig/twig/lib/Twig/Environment.php(289): __TwigTemplate_0094fc48bee2670bd62e7cd8bf24d8783b7878c5328858b06e9a3f958fb33f4a->render()
#17 /home/vagrant/code/vendor/craftcms/cms/src/web/View.php(331): craft\web\twig\Environment->render()
#18 /home/vagrant/code/vendor/craftcms/cms/src/web/View.php(378): craft\web\View->renderTemplate()
#19 /home/vagrant/code/vendor/craftcms/cms/src/web/Controller.php(156): craft\web\View->renderPageTemplate()
#20 /home/vagrant/code/vendor/craftcms/cms/src/controllers/TemplatesController.php(78): craft\controllers\TemplatesController->renderTemplate()
#21 /home/vagrant/code/vendor/yiisoft/yii2/base/InlineAction.php(57): craft\controllers\TemplatesController->actionRender()
#22 /home/vagrant/code/vendor/yiisoft/yii2/base/InlineAction.php(57): ::call_user_func_array:{/home/vagrant/code/vendor/yiisoft/yii2/base/InlineAction.php:57}()
#23 /home/vagrant/code/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams()
#24 /home/vagrant/code/vendor/craftcms/cms/src/web/Controller.php(104): craft\controllers\TemplatesController->runAction()
#25 /home/vagrant/code/vendor/yiisoft/yii2/base/Module.php(528): craft\controllers\TemplatesController->runAction()
#26 /home/vagrant/code/vendor/craftcms/cms/src/web/Application.php(282): craft\web\Application->runAction()
#27 /home/vagrant/code/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction()
#28 /home/vagrant/code/vendor/craftcms/cms/src/web/Application.php(271): craft\web\Application->handleRequest()
#29 /home/vagrant/code/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest()
#30 /home/vagrant/code/public/index.php(21): craft\web\Application->run()
#31 {main}
daltonrooney commented 5 years ago

Confirmed! Thank you, I'll look into this. In the meantime, if you don't add the trackSection value to the config, the plugin will record visits to all entries and the plugin should work normally.