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.

Reassurance on comments

October 01, 2007 11:02pm

Subscribe [4]
  • #1 / Oct 01, 2007 11:02pm

    jeepn

    4 posts

    Hi all,

    I’m trying to NOT display the comment heading if there are no comments.  However, I’m not sure how to get the value of {comment_total} in my conditional so that I can set whether to display it or not.  Can someone take a look at this and tell me if I’m on the right track?

    Thanks

    {!-- Should I put another exp:comment:entries tag here??? if so, where do I close it??? -->
    {if {comment_total} > 0}
    <h2>your thoughts…</h2>
    <p><a name="comments"></a><br />
                <br />
    {exp:comment:entries weblog="{my_weblog}" limit="15"}<br />
    <div class="comment_post"><br />
    <div class="poster_name"><br />
    {url_as_author}<br />
    <span class="poster_details"> ~ {comment_date format='%g:%i %a'} on {comment_date format='%F %j, %Y'}</span><br />
    </div><br />
    <div class="{if {author_id} == 1 OR {author_id} == 2}g_e_comment {/if}comment_text"><br />
    {comment}<br />
    </div><br />
                    <br />
    <hr class="clear" ><br />
    </div><br />
                <br />
    {paginate}<br />
    {if {total_pages} > 1}<br />
    <h4 class="pagination"><br />
    Page {current_page} of {total_pages} comment pages  {pagination_links}<br />
    </h4><br />
    {/if} {!-- Closes if total_pages > 1 --}<br />
    {/paginate}<br />
    {/exp:comment:entries}<br />
    {/if} {!-- Closes if comment_total > 0 near the top --}

  • #2 / Oct 02, 2007 9:14am

    Boyink!

    5011 posts

    Here’s one way (note that I embedd this and pass the weblog name in so I can re-use it):

    <div id="previous_comments">
                    <a name="comments"></a>
                    {exp:comment:entries weblog="{embed:the_weblog}" limit="1"}
                        {if total_results >0}
                            <h2>Previous Comments</h2>
    <p>                    {/if}<br />
                    {/exp:comment:entries}<br />
                    {exp:comment:entries weblog="{embed:the_weblog}"}<br />
                        <div class="single_comment"><br />
                            {comment}<br />
                            <div class="posted">Posted by {url_or_email_as_author}   on  {comment_date format=' %l, %F %d, %Y '}  at  {comment_date format='%h:%i %A'}<br />
                            </div><br />
                        </div><br />
                    {/exp:comment:entries}<br />
                </div></p>
    
    <p>            <div id="comment_form_wrapper"><br />
                    </p><h2>Leave Your Comment</h2>
    <p>                {exp:comment:form}</p>
    
    <p>                    {if logged_out}<br />
                            <br />
                                Name:</p>
    
    <p>                            <input type="text" name="name" value="{name}" size="50" /><br />
                            <br />
                            <br />
                                Email:</p>
    
    <p>                            <input type="text" name="email" value="{email}" size="50" /><br />
                            <br />
                            <br />
                                Location:</p>
    
    <p>                            <input type="text" name="location" value="{location}" size="50" /><br />
                            <br />
                            <br />
                                URL:</p>
    
    <p>                            <input type="text" name="url" value="{url}" size="50" /><br />
                            <br />
                        {/if}<br />
                         <br />
                        <br />
                            <textarea name="comment" cols="50" rows="12">{comment}</textarea><br />
                            </p>
    
    <p>                    {if logged_out}<br />
                             <br />
                            <br />
                                <input type="checkbox" name="save_info" value="yes" {save_info} /> Remember my personal information<br />
                            <br />
                        {/if}</p>
    
    <p>                        <br />
                                <input type="checkbox" name="notify_me" value="yes" {notify_me} /> Notify me of follow-up comments?<br />
                            <br />
                             <br />
        <br />
                        {if captcha}<br />
                            Submit the word you see below:<br />
                            <br />
                                {captcha}<br />
                                </p>
    
    <p>                            <input type="text" name="captcha" value="" size="20" maxlength="20" style="width:140px;" /><br />
                            <br />
                        {/if}</p>
    
    <p>                    <input type="submit" name="submit" value="Submit" /><br />
                    {/exp:comment:form}<br />
                </div>

  • #3 / Oct 02, 2007 11:22am

    jeepn

    4 posts

    Beauty!  Thanks.

  • #4 / Oct 02, 2007 12:06pm

    bobh

    145 posts

    can’t you just do

    {exp:comment:entries}
    
    {if comments}
    {comment}
    
    <div class="posted">Posted by {url_or_email_as_author} on {comment_date format='%m/%d'} at {comment_date format='%h:%i %A'}</div>
    {/if}
    
    {/exp:comment:entries}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases