Problems with the comment-plugin

Hello, as a fresh Kirby user I come right with my first problem to you: I would like to use the comment plugin (GitHub - Addpixel/KirbyComments: [Kirby 2] File-based comments stored as subpages for the Kirby CMS.). I have now inserted

<div class="comments">
  <?php snippet('comments') ?>
</div>

into my /site/templates/article.php, but the result isn’t nice. What am I doing wrong?

I am a Kirby- and PHP-beginner. Thanks for the forbearance. :slight_smile:

You are not doing anything wrong, only there’s no styling included in the plugin. You just have to add custom styles in order to make it suit your needs.

You can have a look at the CSS of the demo page (end of the file), to get started.

Also, you may want to add classes to the snippet elements to facilitate your styling.

Thanks for the quick help.
CSS tells me something, but what do I have to do now in order for the boxes to be intertwined? Which code must be in which file?

Ich habe auch noch ein anderes Problem: In der site/config/config.php habe ich folgendes ergänzt:

c::set(‘comments.email.enabled’, true);
c::set(‘comments.email.to’, array(‘…@…’));
c::set(‘comments.form.preview’, ‘Vorschau’);
c::set(‘comments.form.submit’, ‘Abschicken’);

Ich bekomme bei neuen Kommentaren weder eine eMail, noch werden die beiden Schaltflächen umbenannt - sie bleiben beim Standardwert.

I just had a look in the snippet, and these values are indeed hardcoded, so the config setting doesn’t do anything. You would have to change the value in the snippet itself.

Are you using the starterkit? Then you would have to add your styles in /assets/css/index.css. If you are using any other theme or your own styles, you would have to add those in your stylesheet or the one that belongs to the theme. If you want to use classes for styling, they would also go into the snippet. (The plugin category is only for plugin announcements, not for questions even if they are plugin related, btw).

I think I’ll invite @florianpircher to this topic.

Are you testing this locally or on a remote server?

I have created an issue on GitHub regarding the missing config functionality.

The comments.form.preview and comments.form.submit options describe the name used for HTTP POST data, not the button label. So, for example, a value of

c::set('comments.form.preview', 'comment-preview');

… results in …

<input name="comment-preview" type="submit" ...

This is important to the plugin because it needs to know the name of the buttons/fields in order to read the values from PHP’s $_POST.

The label of the button is not important to the plugin and so it doesn’t need to know about it. (That is why there is not option for button labels.)

You can copy the contents of comments/snippets/comments-form.php and paste them into a new snippet in your sites site/snippets/my-comments-form.php (name it whatever you like). There, you can change it the value of the buttons to something else:

<!-- site/snippets/my-comments-form.php -->
...
<input value="My Preview Button" type="submit" name="<?php echo $comments->previewName() ?>">
...

In order to use the new snippet, change your code from …

<div class="comments">
  <?php snippet('comments') ?>
</div>

… to …

<div class="comments">
  <?php
  // use the standard list of the plugin
  snippet('comments-list');
  // use the new, custom comments form
  snippet('my-comments-form');
  ?>
</div>

For more on creating custom markup check out the Custom Markup guide in Kirby Comments’s README.

Many thanks for the support. Meanwhile, this works with the mail notification. I can not understand why. However, it takes quite a long time for the message to arrive. This is no longer a problem.

Thank you, has worked!

Can you say something more, as far as the layout is concerned, I can not go further.

Your styling depends on your theme or your styles in general, so it’s hard to give any advice. No idea if you use a framework like bootstrap or your own CSS, or whatever. May I asked on what level you’d say is your HTML and CSS knowledge in general?

I certainly give a clear picture: I have almost no CSS and only moderate HTML knowledge.
I use a theme of another developer and had the hope that you can tell me where I can look for such CSS files. The developer himself can not be reached well at the moment.

Well, I don’t know your theme, but I guess you can find the CSS file in /assets/css or a similarly named folder.

Sorry late to the game here… But iv’e på the comment folder in the plugins folder and added the snippet til a template but nothing turns up… Do I have to activate stuff in the config?

Heres my template and where i put the snippet ind the footer…

<?php snippet('header') ?>
<?php snippet('topbar') ?>
<?php snippet('head') ?>
<?php snippet('menu') ?>

	<section class="sub-page container">

		<article class="article">
			<header>
		
				<?php if($cover = $page->image($page->cover())) :?>
				<figure>
					<img src="<?php echo $cover->url() ?>" alt="<?php echo html($page->title()) ?>" />
					<noscript><img src="<?php echo $cover->url() ?>" alt="<?php echo html($page->title()) ?>"/></noscript>
				</figure>
				<?php endif ?>

				<div class="meta-data">
					<h3><?php echo html($page->title()) ?></h3>

				 	<time datetime="<?php echo $page->date('c') ?>"><?php echo $page->date('F dS, Y'); ?></time>

					<?php snippet('share') ?>
				</div>
			</header>

			<div class="entry-content" id="info">

				<?php echo kirbytext($page->text()) ?>
				
			</div>

			<?php if ($page->tags() != ''): ?>
			<footer>
				<ul class="tags">
					<?php foreach(str::split($page->tags()) as $tag): ?>
				          	<li><a href="<?php echo url('tag:' . urlencode($tag)) ?>" class="tag"><?php echo $tag; ?></a></li>
				          <?php endforeach ?>
				</ul>
				
					<div class="comments">
  						<?php snippet('comments') ?>
					</div>

			</footer>
			<?php endif ?>

				

		</article>


	</section>
	
<?php snippet('footer') ?>

Is your folder in. /site/plugins called comments?

YUP…

CloudApp

And everything is in there?

Have you checked. the source. code. to see if the div with the form is really missing or just not. visible because of stylesheet settings?

Solved… I think the Footer div inside the article is only shown if there is declared any tags. I relocated the comment div into the article body on voila!

Thanks again for your help and attention. Really solid work there texnixe👍