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.

Styling the authors comment different from the rest

July 07, 2010 8:11am

Subscribe [2]
  • #1 / Jul 07, 2010 8:11am

    Andrew Munro

    51 posts

    Hi folks,

    I may be missing something crucial here but want I want to do is style the comment for the author who wrote the article so their comments appear different from the others.

    I’ve read many of the other tutorials on how to do this but can’t seem to get it working. I have no membership functionality on the website in question so anyone can post a comment, but the comments are moderated. Is this why it’s not working? because all the other tutorials assume you are logged in first?

    One thing I can’t seem to understand is if I’m the author of the article and I go back to comment on it (and I’m logged into the CMS in another tab), shouldn’t it know that I’m logged in to the CMS? My logged in conditionals don’t seem to have any effect and it seems that I’m logged out all the time.

    Any help appreciated

  • #2 / Jul 07, 2010 8:56am

    Ingmar

    29245 posts

    Please see this article in the wiki to get you started. Moving to Howto.

  • #3 / Jul 07, 2010 10:39am

    Andrew Munro

    51 posts

    Hi Ingmar,

    I tried a couple of those and they didn’t work. If I chuck a {author_id} into each comment they all output as “0”. Even a comment from the author who wrote the article.

    Any ideas? is it ok that I don’t require anyone to login to post a comment?

  • #4 / Jul 07, 2010 11:02am

    Andrew Munro

    51 posts

    Forgot to mention that I’m running the site locally but surely it should still work

  • #5 / Jul 07, 2010 11:19am

    Liam Spencer

    37 posts

    Do you mind showing some code? Preferably the CSS you have, and the code where the comment is shown.

  • #6 / Jul 07, 2010 11:40am

    Andrew Munro

    51 posts

    This is what I’m using currently to no success. There isn’t much going on in the CSS, just making the background of the <li> red so I can see if it works or not. Also checking in firebug, but the class on the <li> never changes

    <ol class="commentList">
        
    {exp:comment:entries sort="asc" dynamic="off" weblog="{segment_2}" url_title="{segment_3}"}
        
        {if no_results}There are no comments so far.{/if}
    
        <li id="comment-{comment_id}" {if entry_author_id == author_id} class="author"{/if}>
        
            <h3>{if url}<a href="http://{url}%22rel=%22external" rel="external nofollow">{/if}{name}{if url}</a>{/if}</h3>
    <p>        {comment_date format="%l"}, {comment_date format="%M %d %Y"}<br />
            {comment} <br />
        </li></p>
    
    <p>{/exp:comment:entries}<br />
    </ol>

  • #7 / Jul 07, 2010 12:17pm

    Liam Spencer

    37 posts

    This is what I’m using currently to no success. There isn’t much going on in the CSS, just making the background of the <li> red so I can see if it works or not. Also checking in firebug, but the class on the <li> never changes

    <ol class="commentList">
        
    {exp:comment:entries sort="asc" dynamic="off" weblog="{segment_2}" url_title="{segment_3}"}
        
        {if no_results}There are no comments so far.{/if}
    
        <li id="comment-{comment_id}" {if entry_author_id == author_id} class="author"{/if}>
        
            <h3>{if url}<a href="http://{url}%22rel=%22external" rel="external nofollow">{/if}{name}{if url}</a>{/if}</h3>
    <p>        {comment_date format="%l"}, {comment_date format="%M %d %Y"}<br />
            {comment} <br />
        </li></p>
    
    <p>{/exp:comment:entries}<br />
    </ol>

    Sorry to keep throwing tasks at you, but have you tried comparing {entry_author_id} and {author_id} for each comment?

    {entry_author_id} = {author_id}

    Add that in and see if any of the entries are equal. This is just the way I troubleshoot things, if anyone has any better ideas then feel free to post!!

  • #8 / Jul 07, 2010 12:27pm

    Andrew Munro

    51 posts

    Good advice,

    Each comment with…
    {entry_author_id} = {author_id}

    Comes out like…
    428 = 0

    428 is the member ID for the super user admin account. Even comments made by a non member come out as 428. Bit stumped on this one. I’ll set up a blank test page and start over, see if it works

  • #9 / Jul 07, 2010 3:19pm

    Ingmar

    29245 posts

    is it ok that I don’t require anyone to login to post a comment?

    Yes, but in this case EE will have no idea who the author was, and treat them all as “Anonymous”, using an id of 0. For this to work your commenters (particularly the original author) will have to login.

  • #10 / Jul 08, 2010 2:50am

    Andrew Munro

    51 posts

    Ok thanks for clearing this up for me, thought I was missing something (first time using comments within EE).

    I’ve got it all working now by simply providing a login form to the authors, and they just need to login and tick the “auto login”. When any of the members in the “authors” group make a comment on the article, their comment will highlight.

    Thanks

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

ExpressionEngine News!

#eecms, #events, #releases