Module

Developer
Supported

Threaded Comments

ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Yuri Salimovskiy

     

You must be logged in to post.

Threaded Comments not displaying on posts with no comments

Support Request

jcastro
jcastro

Hi there. Just trying to figure out why everything works well in a commented post, but nothing, not even the form, or comment count appears on posts with no comments

<!-- Comments -->
<
div class="comments">
<
div class="commentrule"></div>
{exp:threaded_comments:display url_title="{segment_3}"  parent_id="{segment_4}"}
<strong>{total_comments} Comments on "{title}" </strong>
{comment_form} 
{
/exp:threaded_comments:display}


{exp
:threaded_comments:display url_title="{segment_3}" channel="blog" parent_id="{segment_4}"}
<!--{if no_results}  
<p>There are no comments for this entry yet.</p
{/if}

<a href="[removed]void(0)" class="btnreply" rel="0">Reply to entry</a>-->
<
ul>
{comments}
{thread_start}
<ul class="cmt_lvl_{level}">
{/thread_start}
<li>
<
div class="date">{comment_date format="%F %j, %Y"&nbsp;&nbsp;{comment_date format="%g:%i %A"}</div>
<
strong>{url_as_author} wrote:</strong>
<
p
<
div class="comment-text">{comment}</div>
<
a href="[removed]void(0)" class="btnreply" rel="{comment_id}">Reply</a

<
div class="replyform"{comment_form} <class="cancel">Cancel Reply</a></div>
</
p>
</
li><div class="commentrule"></div>

{thread_end}
</ul>
{/thread_end}
{
/comments}
</ul>


{/exp:threaded_comments:display}   

</div>
<!-- 
End Comments --> 

Comment Form Snippet

{exp:threaded_comments:form channel="blog" parent_id="{segment_4}" url_title="{segment_3}"}
{if error}
<span >{error_text}</span>
{if:else}

<div class="commentrule"></div>
<
div class="commentspacer"></div>
<
div class="commentform">
{if logged_out}
<class="input">
<
label for="comment-author">Name *</label>
<
input type="text" name="name" id="comment-author" placeholder="Name" size="22" tabindex="1" />
</
p>
<
class="input">
<
label for="comment-email">Email *</label>
<
input type="text" name="email" id="comment-email" placeholder="Email" size="22" tabindex="2" />
</
p>
<
class="input">
<
label for="comment-website">Website</label>
<
input type="text" name="website" id="comment-email" placeholder="Website" size="22" tabindex="2" />
</
p>
{/if}
<p>
<
label for="comment-message">Comment *</label>
<
textarea name="comment" id="comment-comment" cols="22" rows="5" tabindex="4" placeholder="Comment"></textarea>
</
p>
<!--
Uncomment to save user information
{if logged_out}
<class="input">
<
label for="save_info">
<
input type="checkbox" id="save_info" name="save_info" value="yes" {save_info} /> 
Remember my personal information
</label>
</
p>
{/if}
{if captcha}{captcha}{
/if}-->
<
div class="comment-notify-submit">
<
class="comment-submit">
<
input type="submit" name="Post Comment" value="Post Comment" id="comment-submit" tabindex="5" >
</
p>
<
div class="clear"></div>
</
div>
</
div>
{/if}
{
/exp:threaded_comments:form} 

Thanks!

Yuri Salimovskiy
# 1
Developer
Yuri Salimovskiy

{if no_results}...{/if} chunk should be displayed if there are no comments.
If it does not, then most likely you have threaded comments tag nested inside other EE tag, and that one does not have {if no_results}...{/if} (you need to include no_results inside each EE tag pair to make it work properly)

gudehus
# 2
gudehus

I had the same error and put the exp:threaded_comments:form outside the channel:entry tag.

But If I have no_results, what should I display to enter the first comment as the exp:threaded_comments:form doesn’t display anything.

Catch 22?

Yuri Salimovskiy
# 3
Developer
Yuri Salimovskiy

If exp:threaded_comments:form does not get displayed, most likely it cannot recognize entry_id/url_title
You can either pass one of those as parameter, or omit the parameters to let the script “guess” it

gudehus
# 4
gudehus

It is only displayed on entries that already have a comment.
And the parent_id and url_title parameters are omitted.
I’ve tried to show the normal ee comment code instead but then nothing is entered in the comments.

Yuri Salimovskiy
# 5
Developer
Yuri Salimovskiy

What does your URL look like, and what is your template code

gudehus
# 6
gudehus

This is an entry with comments
http://icscentre.org/news/comments/global-futures

this without
http://icscentre.org/news/comments/post-2015

here is the code

<article class="comments">
    <
header>
    <
h1>Discussion</h1>
    </
header>
    
    
{exp:threaded_comments:display}
    {if no_results}
    {exp
:comment:form channel="news" enable_uploads="y"}
    
    
<textarea name="comment" id="comment-comment" tabindex="4" placeholder="Comment"></textarea>
    </
p>
    <
input type="file" name="userfile[]" /> 
    <
p><input type="submit" name="submit" value="submit" /></p>
    
    
{/exp:comment:form}
    {
/if}
    
<ul>
    
{comments}
    {thread_start}
    
<ul>
    
{/thread_start}
    
<li>
    <
div class="comment-text">{comment}</div>
    
{if uploaded_files}
     
<class="attachment">{uploaded_files_total} file{if uploaded_files_total == 1} is{if:else}s are{/if} attached to this comment:</p>
     
{uploaded_files}
     {if uploaded_file_is_image}
      
<class="attachment"><a href="{uploaded_file_url}"><img src="{uploaded_file_url}" height="{uploaded_file_height}" width="{uploaded_file_width}" alt="image" /></a></p>
     
{if:else}
      
<class="download"><a href="{uploaded_file_url}">Click here to Download this file</a></p>
     
{/if}
     {
/uploaded_files}
    {
/if}
    
    
<class="author">by {url_as_author} on {comment_date format="%d.%m.%Y"}</p>
    <
a href="[removed]void(0)" class="reply" rel="{comment_id}">Reply to this comment</a>
    </
li>
    
{thread_end}
    
</ul>
    
{/thread_end}
    {
/comments}
    
</ul>
    <
p><a href="[removed]void(0)" class="reply" rel="0">Comment on conference</a></p
    
{/exp:threaded_comments:display}
    
    
    {exp
:threaded_comments:form enable_uploads="y" url_title="{segment_3}"}
    
<style>
    
#comment_form {
     
displaynone;
    
}
    
</style>
    <
p>
    <
textarea name="comment" id="comment-comment" tabindex="4" placeholder="Comment"></textarea>
    </
p>
    <
input type="file" name="userfile[]" /> 
    <
p><input type="submit" name="submit" value="submit" /></p>
    
{/exp:threaded_comments:form} 
    
    {
!-- this code will set proper parent_id and move the form --}
    [removed]
    
$(document).ready(function(){
     
$('.reply').click(function() {
      
$('#comment_form input[name=parent_id]').val($(this).attr('rel'));
      $(
'#comment_form').insertAfter// Insert the comment form after...
       
$(this).parent() // The containing p tag
      
);
     $(
'#comment_form').show();
     
});
     $(
'.quote').click(function() {
      
$('#comment_form textarea[name=comment]').val('[quote]'+$(this).parent().parent().find('.comment-text').text()+'[/quote]'
      
);
     
});
    
});
    
[removed]
   
</article
Yuri Salimovskiy
# 7
Developer
Yuri Salimovskiy

The code seems to be correct. Please check that comments are enabled for this entry (it is most common case when form is shown for one entry, and not shown for another one)

Which form is not shown - the ‘native; comment form, or Threaded Comments form?

gudehus
# 8
gudehus

I found it.
Somehow the customer made an entry with the exact url_title in another channel.
If I use another entry with no comments it worked.
Sorry for the mess.
Thanx

danmuprhy
# 9
danmuprhy

loemrntdherid1
# 10
loemrntdherid1