ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Problem with comments_disabled

July 20, 2012 12:14am

Subscribe [1]
  • #1 / Jul 20, 2012 12:14am

    ralph.m

    225 posts

    I have this basic setup for comments and a comment form:

    <h2>Comments</h2>
    <p>{exp:comment:entries channel="blog"}<br />
    {if comments_disabled}Commenting is not available for this entry.{/if}  <br />
    {if no_results}No comments have been posted yet!{/if}<br />
    <div class="comments"><br />
     <div>{url_as_author} <span>— {comment_date format="%F %d, %Y"}</span></div><br />
     <div>{comment}</div><br />
    </div>{/exp:comment:entries}<br />
      </p><h2>Make a comment</h2>
    <p>{exp:comment:form channel="blog"}<br />
     ... form code here ...<br />
    {/exp:comment:form}

    If I disable comments in a particular blog post, I was hoping that

    {if comments_disabled}Commenting is not available for this entry.{/if}

    would kick in, but it doesn’t. So I get a comment that nothing’s been posted yet, then the Make a Comment heading, and a default message from the system:

    Commenting is not available in this channel entry.

    Am I doing something wrong here?

    What I’d really like is that, if comments are disabled for an entry, I’d just get the title “comments” and then the comments_disabled message.

    Thanks for any suggestions. 😊

  • #2 / Jul 20, 2012 10:27am

    Kevin Smith

    4784 posts

    Hi ralph.m,

    There are a couple of things going on here. First, the comments_disabled conditional is only available in the exp:comment:form tag, so you’re using it in the wrong place. The second thing is that you’ll want to include the “Make a comment” header within the exp:comment:form tag so that it doesn’t show if comments are disabled. Anything outside that tag will be output whether or not comments are disabled.

    Does that make sense?

  • #3 / Jul 21, 2012 4:50am

    ralph.m

    225 posts

    Ah, thanks a million, Kevin. That’s what I was doing wrong. Working nicely now. 😊

    Just to make the code a bit nicer, I changed the heading to a legend, since it was inside the form. In case anyone else has this problem, here’s the basic code I used:

    <h2>Comments</h2>
    <p>{exp:comment:entries channel="blog"}<br />
    {if no_results}No comments have been posted yet!{/if}<br />
    <div class="comments"><br />
     <div>{url_as_author} <span>— {comment_date format="%F %d, %Y"}</span></div><br />
     <div>{comment}</div><br />
    </div>{/exp:comment:entries}<br />
      <br />
    {exp:comment:form channel="blog"}<br />
    {if comments_disabled}Commenting is not available for this entry.{/if}  <br />
    <fieldset> <br />
     <legend>Make a Comment</legend><br />
        <br />
     <label for="name">Name</label><br />
     <input name="name" type="text" id="name" value="{name}"><br />
        <br />
     <label for="email">Email Address</label><br />
     <input name="email" type="text"  id="email" value="{email}"><br />
        <br />
     <label for="url">Website</label><br />
     <input name="url" type="text" id="url" value="{url}"><br />
       <br />
     <label for="comment">Comments</label><br />
     <textarea name="comment" id="comment">{comment}</textarea><br />
        <br />
     <input type="submit" name="submit" value="Post Comment"><br />
    </fieldset><br />
    {/exp:comment:form}

    PS - I fear you took your avatar picture after reading my post. 😊

  • #4 / Jul 23, 2012 6:02pm

    Kevin Smith

    4784 posts

    Ha! Oh, the support team gives me a ribbing for that avatar every now and again. It’s a classic.

    Glad to see it’s all working nicely! And thanks so much for posting it back here for others’ benefit. If there’s anything else you need, just let me know!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases