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.

Hiding comment header in all but single entry page

November 06, 2007 3:05pm

Subscribe [1]
  • #1 / Nov 06, 2007 3:05pm

    guerrilla

    31 posts

    Using the index template, I want to have a header appear above the comments and with the comments whenever the page is a single entry. I’ve tried a segment conditional

    {if segment_2 != ""}<h3>Comments</h3>{/if}

    which works for the index page except the comments header also appears on other aggregate pages and not just the single entry page. I can’t figure out how to limit it to just the actual entry page for the post.

    The clients want the comments and option for comments to appear on the same page as the articles. It seems to confuse them when they have to link to the comments…

    Anyone have a simple solution?

    I know this is rather basic, but for some reason some of the most basic issues are proving the hardest on this site dev.  :red:

  • #2 / Nov 07, 2007 12:59am

    guerrilla

    31 posts

    Problem solved by thinking differently. Since I’ve already managed to solve the problem of showing the comments on the single entry, I used the a conditional count to determine when to display the “Comments” header. Here’s the bit of code:

    {exp:comment:entries weblog="{embed:weblog}" limit="25"}
    {if no_results}
    No one has commented yet. Be the first.
    {/if}
    {if {count} == "1"}
    <h3>Comments</h3>
    <p>{/if}<br />
    <div class="comments"><br />
    {comment}<br />
    .<br />
    .<br />
    .

    It’s now working fine. 😊

  • #3 / Nov 07, 2007 1:03am

    guerrilla

    31 posts

    Nope, sorry. I spoke too soon. Adding new comments makes it add the header. Buggerit! Millennium shrimp and hand!  :down:

  • #4 / Nov 07, 2007 1:28am

    guerrilla

    31 posts

    Okay, this looks like it’s working. I’m certain there’s a more elegant solution, but since no one has offered it, I’ll post this one:

    .
    .
    .
    {if segment_2 != "" && segment_3 == {url_title}}
    <h3>Comments</h3>
    <p>{/if}</p>
    
    <p>{exp:comment:entries weblog="{embed:weblog}" limit="25"}<br />
    .<br />
    .<br />
    .

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

ExpressionEngine News!

#eecms, #events, #releases