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.

{if allow_comments} is not working

May 03, 2009 11:04pm

Subscribe [3]
  • #1 / May 03, 2009 11:04pm

    shahW

    12 posts

    Hi all,

    I’m currently having problem with {if allow_comments}. No matter what the commenting status on an entry, whether it’s allowed or not. The form just refused to do display.

    FYI: I’ve looked everywhere on the EE forum for users who might have the same problem as me. But, none avail.

    The EE form tag is not enclosed within a weblog:entries. And I have double checked again and again. Spent a good 4-5hrs last night trying to get this thing to work but none avail.

    {if allow_comments}
            {exp:comment:form weblog="notes"}
                <div id="addComment">
                        <!--- comment total= <?php echo "$comm_total" ?> -->
                    <h5><a href="#"><span><strong>+</strong></span> Add Your Comment</a></h5>
    <p>            </div><!-- end addComment-->        </p>
    
    <p>            <div id="addCommentForm"><br />
                    <fieldset><br />
                        <ul><br />
                            <li><br />
                                <label class="name">Name</label><br />
                                <input name="name" type="text" class="txt" value="{name}" maxlength="255"/><br />
                            </li><br />
                            <li><br />
                                <label class="name">Email</label><br />
                                <input name="email" type="text" class="txt" value="{email}" maxlength="255"/><br />
                            </li><br />
                            <li>    <br />
                                <label class="name">Website</label><br />
                                <input name="url" type="text" class="txt" value="{url}" maxlength="255"/> <br />
                            </li><br />
                            <li>    <br />
                                <label class="name">Comment</label><br />
                                <textarea name="comment" cols="25" rows="8" wrap="virtual">{comment}</textarea><br />
                                </p>
    
    <p>                            <input name="notify_me" id="notifyMe" type="checkbox" value="" class="checkbox" {notify_me}  /> <label for="notifyMe" class="checkLabel">Notify me of follow-up comments ?</label><br />
                            </li>                    <br />
                        {if captcha}<br />
                            <li>    <br />
                                <label class="name">No Spam</label><br />
                                {captcha}<input type="text" name="captcha" value="" maxlength="255" class="captcha"/><br />
                                <span>Please type the letters and numbers you see into the box provided</span> <br />
                            </li><br />
                        {/if}            <br />
                            <li><input class="submit" type="submit" name="submit" value="Submit »" /></li><br />
                        </ul><br />
                    </fieldset><br />
                </div><br />
                <br />
            {/exp:comment:form}<br />
        {if:else}<br />
            <div id="commentClosed"><br />
                </p><h5><span><strong>X</strong></span> Comment is closed</a></h5>
    <p>        </div><!-- end commentClosed-->    <br />
        {/if}

    Please kindly advice what to do.

    The EE version I’m using is EE Full (personal) v.1.6.7 Build:  20090211

    Thanks
    -sw

  • #2 / May 04, 2009 1:27am

    Lisa Wess

    20502 posts

    The conditional is only valid within the weblog entries tag.  The comment form is its own conditional, it won’t show if comments are closed.

  • #3 / May 04, 2009 2:02am

    shahW

    12 posts

    Hi Lisa,

    Are you saying that conditional ONLY works if it was inside {exp:weblog:entries} {/exp:weblog:entries}? I thought, it’s a good practice to separate {exp:comment:form} from {exp:weblog:entries}? I’m confused :(

  • #4 / May 04, 2009 2:23am

    John Henry Donovan

    12339 posts

    shahW,

    What Lisa means that that particular conditional is used for the inside of the weblog entries tag and not wrapping the comment tags

    For example you might use it like this

    {if allow_comments}This post has {comment_total} comments{/if}

    The comment tags do not need conditionals because if you turn off commenting, they will not show regardless.

    So take your example and approach it with this knowledge now.

    {exp:weblog:entries weblog="your_weblog" limit="1"}
    
    {if allow_comments}
    
            <div id="addComment">
                        <!--- comment total= {comment_total} -->
                    <h5><a href="#"><span><strong>+</strong></span> Add Your Comment</a></h5>
    <p>            </div><!-- end addComment--> <br />
     <br />
    {if:else}</p>
    
    <p><div id="commentClosed"><br />
                </p><h5><span><strong>X</strong></span> Comment is closed</a></h5>
    <p>        </div><!-- end commentClosed--> <br />
     <br />
    {/if}</p>
    
    <p>{/exp:weblog:entries}</p>
    
    <p><br />
    {exp:comment:form weblog="notes"}<br />
              </p>
    
    <p>            <div id="addCommentForm"><br />
                    <fieldset><br />
                        <ul><br />
                            <li><br />
                                <label class="name">Name</label><br />
                                <input name="name" type="text" class="txt" value="{name}" maxlength="255"/><br />
                            </li><br />
                            <li><br />
                                <label class="name">Email</label><br />
                                <input name="email" type="text" class="txt" value="{email}" maxlength="255"/><br />
                            </li><br />
                            <li>    <br />
                                <label class="name">Website</label><br />
                                <input name="url" type="text" class="txt" value="{url}" maxlength="255"/><br />
                            </li><br />
                            <li>    <br />
                                <label class="name">Comment</label><br />
                                <textarea name="comment" cols="25" rows="8" wrap="virtual">{comment}</textarea><br />
                                </p>
    
    <p>                            <input name="notify_me" id="notifyMe" type="checkbox" value="" class="checkbox" {notify_me}  /> <label for="notifyMe" class="checkLabel">Notify me of follow-up comments ?</label><br />
                            </li>                    <br />
                        {if captcha}<br />
                            <li>    <br />
                                <label class="name">No Spam</label><br />
                                {captcha}<input type="text" name="captcha" value="" maxlength="255" class="captcha"/><br />
                                <span>Please type the letters and numbers you see into the box provided</span><br />
                            </li><br />
                        {/if}            <br />
                            <li><input class="submit" type="submit" name="submit" value="Submit »" /></li><br />
                        </ul><br />
                    </fieldset><br />
                </div><br />
                <br />
            {/exp:comment:form}

  • #5 / May 04, 2009 2:35am

    shahW

    12 posts

    John,

    Thanks for the prompt reply. Appreciated it 😊

    I think, I somewhat understand of what is required. BUT, my question now is, when allow comment for an entry is disabled or closed, how would I be able to control of what text that is generated by EE? Currently, it defaulted to “Commenting is not available in this section entry.” Or this text will not show at all, if I had used {if allow_comments}{/if}? As per example given above


    Apology for asking such basic question. But, this is the only way for me to learn 😊


    Thanks
    -sw

  • #6 / May 04, 2009 3:11am

    John Henry Donovan

    12339 posts

    how would I be able to control of what text that is generated by EE?

    The default text will always appear.

    You could always modify line 18 or /system/language/english/lang.comment.php to be blank, or another message of your choosing.

    Moving this to the ‘How to’ forum as it may be helpful for other users

  • #7 / May 04, 2009 3:28am

    shahW

    12 posts

    Thanks John!

    This is cool stuff. But how I wish that allow_comments would work on the form tag. Or some way of flagging the commenting status of an entry, instead of meddling with the system files 😊

  • #8 / May 04, 2009 12:26pm

    Lisa Wess

    20502 posts

    Changing the language is simply a matter of creating your own language pack; that’s a supported thing, not a hack.  Search the docs for “translation utility” and “using your own language pack” for info.

    And of course, you can always submit a feature request. =)

  • #9 / May 04, 2009 9:16pm

    shahW

    12 posts

    Is there a way for me to create a php variable that can be used within EE form tag? If so, how to use raw php var within EE tag?

    I’m thinking, I could do a quick check within

    {exp:weblog:entries weblog="my_weblog" limit="1"}
       {if allow_comments}
          <?php $allowComm=true ?>
       {if:else}
          <?php $allowComm=false ?>
       {/if}
    {/exp:weblog:entries}
    
    {if $allowComm}
       {exp:comment:form weblog="notes"}
           {!-- form fields here---}
       {/exp:comment:form}
    {if:else}
           {!-- show some message here---}   
    {/if}
  • #10 / Jul 13, 2009 11:15pm

    DougH

    205 posts

    The conditional is only valid within the weblog entries tag.  The comment form is its own conditional, it won’t show if comments are closed.

    Lisa,

    I’m running the current version and build of EE and have “allow comments” unchecked on a particular entry. However, the comment form is still visible.

  • #11 / Jul 14, 2009 12:36am

    Lisa Wess

    20502 posts

    Doug please start a new thread in technical support. =)

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

ExpressionEngine News!

#eecms, #events, #releases