I am following the Comments template from A to Z tutorial to create a comment section. I want to show all approved comments and unapproved comments in case it is the comment’s author viewing the page.
The layout I want to achieve are discussions divided by a line separator. I am defining a discussion as a comment and all of its replies. Below is an example of the layout:
To style the discussion, I’m targeting the div with the cc-query-item class with relative styling. The problem with this is that the div element of the cc-query-item of an unapproved comment is always rendered on the frontend. Even if the user viewing the page is not the unapproved comment’s author. What I end up with is an extra separator. See below:
I’m not able to figure out a way to not render a div element of an unapproved comment (if the user is not the comment’s author). The only class it has is the cc-query-item and it’s shared with all other comments.
Any idea how to solve this? Maybe there is a much simpler approach I’m missing.
The second solution does not work because .comment class is given to every comment, even if it’s a reply to different comment. I want have the line separate between groups of comment (what I call discussions).
The first solution should work but maybe I am doing something wrong. The .cc-query-item div is not empty, but its child is. See below (comment-41):
Wrapping the entire contents of your Query Template with a Div block with a class (e.g. comment-group) and changing the relative style to target that instead may solve the issue - because you can then apply the relevant visibility condition/s to that instead.
Unfortunately this doesn’t work. Wrapping the entire content of the Query Template ends up wrapping a single comment. Here is what Cwicly outputs without wrapping the content of the Query Template:
<div id="query-xxxx" class="query-yyyy">
<div id="query-template-xxxx" class="query-template-yyyy">
<div class="cc-query-item"> <!-- Holds top level comment and its replies -->
<div id="comment-nn" class="comment c-query"> <!-- Holds a single comment -->
</div>
<div class="cc-query-child"></div> <!--Holds replies to comment-nn -->
</div>
<div class="cc-query-item"></div>
<div class="cc-query-item"></div>
<div class="cc-query-item"></div>
</div>
</div>
This is what Cwicly outputs after wrapping the Query Template:
<div id="query-xxxx" class="query-yyyy">
<div id="query-template-xxxx" class="query-template-yyyy">
<div class="cc-query-item"> <!-- Holds top level comment and its replies -->
<div id="comment-nn" class="comment c-query"> <!-- Holds a single comment -->
<div class="comment-group"> <!-- This div wraps all the content of the Query Template -->
</div>
</div>
<div class="cc-query-child"></div> <!--Holds replies to comment-nn -->
</div>
<div class="cc-query-item"></div>
<div class="cc-query-item"></div>
<div class="cc-query-item"></div>
</div>
</div>
Yes, I did a quick test and confirm exactly what you are seeing.
@Araminta, as you did the useful demo video, is there any advice you can give?
As the comments query behaves slightly differently, and the hierarchical output is only nested with the cc-query-item, the usual strategies don’t work for it.