Methods

Page methods

$page->comments()

Returns all published comments of a page.

$page->comments(): Kirby\Cms\Structure

Return type

Kirby\Cms\Structure

Example

<?php $commentList = $page->comments(); ?>
<ul>
<?php foreach($commentList as $comment): ?>
    <li>
        <?= $comment->authorname(); ?> wrote <?= $comment->content()->kt(); ?>
    </li>
<?php endforeach(); ?>
</ul>

$page->commentCount()

Returns the number of published comments of a page.

$page->commentCount(): int

Return type

int

Example

<p>There are <?= $page->commentCount(); ?> published comments on this page</p>

$page->commentsAreEnabled()

Returns if the comment functionality of a page is enabled. It can be disabled in different ways.

$page->commentsAreEnabled(): bool

Return type

boolean

Example

<?php if($page->commentsAreEnabled()): ?>
<!-- Show the comment form -->
<?php endif; ?>

Site methods

$site->numberOfPendingComments()

Returns the number of pending comments from all pages.

$site->numberOfPendingComments(): int

Return type

int

Example

<p>There are <?= $site->numberOfPendingComments(); ?> comments waiting to be approved</p>

$site->numberOfSpamComments()

Returns the number of comments from all pages marked as spam.

$site->numberOfSpamComments(): int

Return type

int

Example

<p>There are <?= $site->numberOfSpamComments(); ?> spam comments waiting to be deleted</p>