Closed liaprins closed 6 years ago
You can create custom templates for comments- and comment-pages by creating site/templates/comments.php
and/or site/templates/comment.php
. There you can place any template code you would like, e.g. <?php if (!$site->user()) go('/') ?>
.
This way you don’t have to edit the plugin files directly.
Wow, thanks! That worked perfectly.
Hi there,
I have been hiding a few of the "pages" (folders within the content folder within Kirby's setup) so that no one can reach them from the browser. For example, I have parent pages for each of my image galleries that holds the images as children which are then pulled into the actual post page: I don't want anyone to go to the gallery parent page. I have been using this method from Kirby docs: https://getkirby.com/docs/cookbook/authentication#protecting-content which instructs to simply add
<?php if(!$site->user()) go('/') ?>
at the top of templates to hide.Then I tried it on the comments and comment templates, located within the site/plugins/comments/plugin folder. However, I get a breaking error of "Undefined variable: site" because
$site
cannot be recognized in these deep down files, I think.I do not know PHP (or Kirby?) quite enough to figure out how to define
$site
from the vantage point of these deep plugin files. Do you know how to fix this? Or if there is another way to prevent the /comments and /comments/comment-1, etc pages from being reached by the public?Thanks so much!