I have a problem with the plugin "Comments". I have the plugin installed and activated. Also in the file: item.html.twig the following line of code inserted:
{% include 'partials/comments.html.twig' with {'page': page} %}
Unfortunately, I do not get an issue or reaction. Does anyone have a similar problem or does anyone have an idea why it might be.
@codiergott If the route of the page on which you want to add comments does not start with '/blog', you need to add that route in 'user/config/plugins/comments.yaml' like:
'$path' is the path of the page you are visiting and is relative, like '/techwiki/mytopic'.
'$route' is the route listed in 'enable_on_route' and should also be relative.
Note the forward slashes...
If the url of the blog is 'https://meineurl/techwiki', the settings in 'comments.yaml' should be like:
TXT
enable_on_routes:
- /techwiki
Every blog topic below '/techwiki' should now contain comments.
If this doesn't help I have the following questions:
Which theme are you using?
What is the folder structure?
What is the name of the page (*.md) that should contain the comments?
@pamtbaau:
Every blog topic below ‘/techwiki’ will now contain comments.
Thank you for your help. The 'enable_routes' I have checked and are entered correctly. I think I have another problem here. I added the following lines of code in the comments.html.twig, in the Comments plugin folder:
This leads me to suspect that the routes you have set in 'comments.yaml' are not correct.
Do you know how to debug and read the variables $path and $route?
If not, you could print the variables to the console of the browser. Change the above script like:
PHP
if(!in_array($path,$disable_on_routes)){if(in_array($path,$enable_on_routes)){$this->enable=true;}else{foreach($enable_on_routesas$route){echo"<script>console.log('$path| $route');</script>";// Add this lineif(Utils::startsWith($path,$route)){$this->enable=true;break;}}}}
Refresh the browser and open the console of the browser (How to for: Chrome, Firefox, Safari). You should see something like the following:
Thanks for the code. He helped me a lot. I receive the following edition:
/techwiki/sonstiges/dyndns-domain-mit-ssl-support-auf-einer-fritzbox-einrichten | /blog
How can I change the second value? Find this nowhere in the settings. Adding / blog to the enable_on_routes will not work either.
'/techwiki/sonstiges/dyndns-domain-mit-ssl-support-auf-einer-fritzbox-einrichten' is the value of $path which is the url of the page on which you want to see comments.
'/blog' is the value of $route which is looping through the values of 'enable_on_routes' in either '/user/config/plugins/comments.yaml' or the original '/user/plugins/comments/comments.yaml'
The default values in ‘/user/plugins/comments/comments.yaml’ are:
TXT
enable_on_routes:
- '/blog'
Because the console only shows the entry /blog, you probably haven't added '/techwiki' to enable_on_routes in the right place.
You can override the default settings of 'comments' plugin by copying the file '/user/plugins/comments/comments.yaml' to '/user/config/plugins/comments.yaml' and update the new 'comments.yaml' as follows:
TXT
enable_on_routes:
- '/blog' // This value may be removed if you're not going to use /blog in your site.
- /techwiki