x
 
Create New Page
 View Previous Changes    ( Last updated by Mark Bowen )

Highlight Author Comments

Question:

On the comments page, I would like to apply a different css class to all comments that are from the original author of the article. Feasible?

Answer:

This can be accomplished as long as you don’t mind some CSS in your <head>. Both the comments and weblog entry tags have {author_id} as a variable so try something like this around your comments

{exp:comment:entries}
<div class="comment author{author_id}">
{comment}
</div>
{/exp:comment:entries}

Then in the <head>, do something like this.

{exp:weblog:entries limit="1"}

<style type='text/css'>
.
author{author_id} {
border
: 1px solid #CC0000;
}
</style>

{/exp:weblog:entries}


The extra ‘comment’ class is just what you would apply to all comments.

——————————————————————————————————
Edit by Mark Bowen - 26/03/08

One other add-on to this is by doing the following :

{exp:comment:entries}
{if entry_author_id
== author_id}
<div class="author-comment">{comment}</div>
{if:else}
<div class="comment">{comment}</div>
{/if}
{
/exp:comment:entries}

You can then just have :

.author-comments {
        border
: 1px solid #ccc;
        
font-weight: bold;
}
.comment {
        whatever you wish here
;
}

or whatever else you would like to do to just the authors comment. Slightly easier now that there is the entry_author_id variable.
——————————————————————————————————

Category:Comments Category:Tips

Categories: