When fetching comments for a page, they are returned as a Structure. You can use the fields to filter and sort them as you would do with Kirby pages:
<?php
$commentList = $page->comments();
if ($comments = $commentList->filterBy('type', 'comment')) {
// DO SOMETHING
}
?>
All available fields of a comment can be used as you would do with page fields:
<?= $comment->FIELDNAME()->kt(); ?>
Available fields
Field | Type | Values | Description |
---|---|---|---|
id |
string | The ID of the comment | |
pageUuid |
string | The ID of the page the comment was posted on | |
parentId |
string | In case of a reply, the ID of the comment replied to | |
type |
enum | SEE BELOW | The type of comment |
content |
string | The actual text of the comment | |
authorName |
string | The name of the comment author | |
authorAvatar |
string | An URL of the avatar of the comment author | |
authorEmail |
string | The email address of the comment author (if enabled) | |
authorUrl |
string | The website URL of the comment author | |
published |
bool | true | false |
Determines if the comment is published or not |
verified |
bool | true | false |
Determines if it is a comment by a verified author |
spamlevel |
int | 0-100 | Set by the spam checks, the higher to more likely it is spam |
language |
string | de | en | ... |
In case of a multilanguage site, the language code of the page the comment was posted on |
upvotes |
int | Number of upvotes for a comment (wip) | |
downvotes |
int | Number of downvotes for a comment (wip) | |
createdAt |
datestring | When the comment was created | |
updatedAt |
datestring | When the comment was modified | |
permalink |
string | /@/comment/ID |
The permalink of the comment on the website |
Comment types
There are several comment types. The default one is comment
. There can be more type, when you receive Webmentions via the IndieConnector plugin.
Type | Description |
---|---|
comment |
A comment sent via the comment form or from within the panel |
in-reply-to |
A reply sent via Webmention |
mention-of |
A mention sent via Webmention |
like-of |
A like sent via Webmention |
repost-of |
A repost sent via Webmention |
bookmark-of |
A bookmark sent via Webmention |
rsvp |
An event response sent via Webmention |
invite |
An invitation sent via Webmention |
Kommentar schreiben