Thread tagged as: Question, Blog, Comments

How can I output comments by type?

I love the new Webmentions functionality! Thinking about the optimal way to display comments now that I have Webmentions set up, I would like to try and get something like this:

// actual comments 
// comments of type ‘Share’: as they appear now 
// comments of type ‘Like’: A, B, C, D and E liked this post
// comments of type ‘Retweet’: F, G and H retweeted this post

(In which A-H would maybe be the people, and maybe be links to the actual tweets?)

So my question is: can I get arrays of comments by type, in order to do something like the above?

Hidde de Vries

Hidde de Vries 0 points

  • 4 years ago

I'm using <perch:if> conditionals in my comment.html template to do something similar.

@Clive: that sounds very useful. Should something like <perch:if type="Like"> work? If I try that, all the comments seem to get matched, so I'm probably doing it wrong. Curious what your comment.html looks like!

I'm using <perch:if id="webmentionType" value="like">

My comment.html template below. Still testing this. And I'm only differentiating between Likes and Reposts in the webmentions section at the moment.

    <h2>Comments and Responses</h2>
    <ul class="comments listing">
<perch:if id="webmention" value="1">
<!-- webmentions section -->
<li class="webmentionlistitem"><perch:blog id="commentName" type="text" label="Name" order="1" required="true" /> <a href="<perch:blog id="commentURL" type="url" label="URL" order="3" />"><perch:if id="webmentionType" value="like">liked<perch:else />reposted</perch:if></a> this</li>
<perch:else />
<!-- regular comments -->
<li id="comment<perch:blog id="commentID" type="hidden" />">
            <img src="//<perch:blog id="commentEmail" type="email" label="Email" order="2" hash="md5" required="true" />?s=120&d=mm" width="60" height="60" />

            <div class="comment">
                <div class="commenter">
                    <perch:if exists="commentURL"><a href="<perch:blog id="commentURL" type="url" label="URL" order="3" />"></perch:if>
                        <strong><perch:blog id="commentName" type="text" label="Name" order="1" required="true" />:</strong>
                    <perch:if exists="commentURL"></a></perch:if>
                <p rel="bookmark" class="date"><perch:blog id="commentDateTime" format="%d %b %Y %X" type="date" time="true" label="Date" /></p>
                <perch:blog id="commentHTML" encode="false" html="true" type="textarea" label="Message (HTML)" order="4" />


Other smarter ways of doing this may be available :-)

I'm using Bridgy to generate the Likes etc. as described in Drew's post.

Oh thanks for this, that's brilliant! Will have a play with it (in fact I have, locally… works a charm)

I did not know id="webmention" was something that could be used there. What would be the best place to find out about the attributes that can be used in <perch:if>?

You can use <perch:showall /> in your template to see what fields are available, see

Also, the <perch:if> docs here

Hi Clive! Sorry I did go a bit off topic there. But many thanks for sharing this, I had no idea this existed! Cheers!