Comments not working like pages?

I’m trying to use Addpixl’s kirbyComments plugin for a list where people can sign up.
(This is just a quick&dirty workaround)
Once a date has a submitted comment, I would like to hide the comment-form.

My way of doing this would be to filter for listed comments:
<?php if($page->grandChildren()->isListed()): ?>

But this does not seem to work. Is as comment not recognised as grandChildren?
Might it have to do with the fact that I’m running Kirby 2.5.6 on this page?
(I can filter for the children() but then the form will disappear, before I can submit the preview.)

I’ll pick this up tomorrow :sleeping:

isListed() is a page method, not a (pages) collection method.

You could check if there are any listed grandchildren like this:

<?php if($page->grandChildren()->listed()->isNotEmpty()): ?>

Or probably rather isEmpty() instead of isNotEmpty()

Dear @texnixe, thanks for your reply.
Both suggested lines will return:

Error
Call to a member function isNotEmpty() on null!

This is how a submitted comment looks:
comments
A not yet submitted one only has the comments folder and the comments.txt.

That is weird. Could you please post your complete code context?

<?php snippet('header') ?>

  <main class="main" role="main">
    <div class="thirtysix">
      	<div class="dates-sub">
          <div class="month"><?= $page->month() ?> <?= $page->day() ?></div>
          <div class="big"><span class="strong"><?= $page->letter() ?></span></div>
          <div class="comments-list">
            <?php snippet('comments-list') ?>
          </div>
            ...
          <?php if($page->grandChildren()->listed()->isNotEmpty()): ?>
          
          <?php else: ?>
          	<div class="comments-form">
	            <?php snippet('comments-form') ?>
	          </div>
          <?php endif ?>
        </div>
        <br>
		<h3><a href="../thirtysix">Back</a></h3>
    </div>
    
  </main>

<?php snippet('footer') ?>

Ah, I totally missed that you are still on Kirby 2. Not obvious from the category.

<?php if ($page->grandChildren()->visible()->count() > 0): ?>
1 Like

Perfect! Thank you so much :slight_smile:
We might update to 3 at one point, but things are working fine for now.