Comments Enabled

The {{ meerkat:comments_enabled }} tag reports whether the current thread accepts comments.

#Example

1{{ if {meerkat:comments_enabled} }}
2 {{ meerkat:form }}
3 ...
4 {{ /meerkat:form }}
5{{ else }}
6 <p>Comments are closed for this entry.</p>
7{{ /if }}
1@php($enabled = Statamic::tag('meerkat:comments_enabled')->params(['thread' => $id])->fetch())
2@if ($enabled)
3 <s-meerkat:form>
4 ...
5 </s-meerkat:form>
6@else
7 <p>Comments are closed for this entry.</p>
8@endif

#When comments are closed

The tag returns false (closed) when either of these is true:

  1. Comments are disabled on the entry. The configured field, comments_closed by default, is enabled.
  2. Automatic close period. publishing.automatically_close_comments is greater than zero and the entry date is older than the specified number of days.

Otherwise, the tag returns true.

#Disable comments on an entry

To allow moderators to close comments on individual entries, add a toggle field to your entry blueprint:

1-
2 handle: comments_closed
3 field:
4 type: toggle
5 display: Close Comments
6 instructions: Disable new comments on this entry.
7 default: false

Set meerkat.publishing.entry_disable_field to another field handle, or null to disable per-entry closure.

#Frontend and Control Panel replies

Entry settings and automatic closure work differently on the frontend and in the Control Panel:

Path Per-entry comments_closed flag Auto-close window
Public form (POST /!/meerkat/comments) Blocks the submission Blocks the submission
Control Panel inline reply (Stack drawer or comment-view reply) Blocks the submission Not applied, so moderators can revive an old thread

#Close comments after a set time

Set Automatically Close Comments on the Meerkat settings page to a number of days. Meerkat rejects comments on entries older than this value. 0 disables automatic closure.

#Parameters

Parameter Default Notes
thread / from_thread current context Choose a specific thread.

Was this page helpful?