This thread is a discussion for the wiki article: Style Comments by Author
   
 
Style Comments by Author
Posted: 22 June 2008 01:35 PM   [ Ignore ]  
Summer Student
Total Posts:  7
Joined  02-10-2008

I am having problem with comments styling, I tried all of the methods written here.

What happens is that somehow EE doesn’t recognize who wrote the comment, it bases div formatting on who is logged atm, and displays all comments in same formatting.

I used CSS formatting and have 2 classes, 1 for guests and 1 for superadmins.

Anyway I want EE to display comments to everyone in same manner, just to display comments from admin user in different color.

Hope I made myself clear.

Thanks in advance.
Igor

Profile
 
 
Posted: 23 June 2008 12:42 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
RankRank
Total Posts:  236
Joined  11-20-2007

Here’s a stripped down version of what I’m using:

{if author_id == '0'}
<div class="othercomment"}>
{comment}
</div>
{/if}

{if author_id
== '1'}
<div class="authorcomment">
{comment}
</div>
{/if}

I’m the only member of my site. You might want to try {member_group} instead of {author_id}.

 Signature 

Tim


TVMCalcs.com - New and Improved! Now proudly powered by EE.

Profile
 
 
Posted: 23 June 2008 03:10 AM   [ Ignore ]   [ # 2 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6543
Joined  04-15-2006

Not totally sure what it is that you want but there is another WIKI post with a method that I wrote up which deals with something like this.

Again, not sure if this is what you are after or whether you want for all members of a certain group to have their posts in a different style? The method I have written up makes the original author of the post have their comments come up differently.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 24 June 2008 05:46 AM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  7
Joined  02-10-2008

I still can’t get this to work :( so I’m pasting the current code (from it you can also see what I am using for avatars - since they are also not working, EE pulls post author avatar for all comments.

btw. site link is http://www.tinstock.com/blog smile

{exp:comment:entries weblog="tinblog" sort="asc" limit="20"}
<div class="comment">

{if author_id == "0"}<div class="comment_tins">
<
img src="{avatar_url}" width="{avatar_image_width}" height="{avatar_image_height}" alt="{author}'s avatar" class="avatar">
<
div class="comment_data"><span class="username">{name}</span> | {comment_date format=" %l, %F %d, %Y "} at {comment_date format="%h.%i %a"}</div>
<
p>{comment}</p></div>{/if}

{if  author_id
== "1"}<div class="comment_all">
<
img src="{avatar_url}" width="{avatar_image_width}" height="{avatar_image_height}" alt="{author}'s avatar" class="avatar">
<
div class="comment_data"><span class="username">{name}</span> | {comment_date format=" %l, %F %d, %Y "} at {comment_date format="%h.%i %a"}</div>
<
p>{comment}</p></div>{/if}

<div class="comment_divider"></div>
</
div>

{/exp:comment:entries}

I am probably making really stupid mistake, I just can’t figure it out :(

I am thinking it may have something to do with comment submission form now…

Thanks in advance

Profile
 
 
Posted: 24 June 2008 06:58 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  881
Joined  02-15-2008

What’s the result if you write the value of each author_id to the screen? As in:

{exp:comment:entries weblog="tinblog" sort="asc" limit="20"}
{author_id}
<br />
{/exp:comment:entries}

 Signature 

Andy Harris | Pepper Digital | Malvern, UK | Twitter | New to ExpressionEngine? Start here!
Remember - If at first you don’t succeed, you’re not Chuck Norris

Profile
 
 
Posted: 24 June 2008 07:03 AM   [ Ignore ]   [ # 5 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6543
Joined  04-15-2006

Okay,

No promises on this one as I am at work at the moment and this plugin that I have attached is very rough but I’m pretty sure it should do what you are asking for though.

Plugin Usage

{exp:group_comment member_id="{author_id}" group_id="1"}

{if belongs_to_group}
<p class="admin-comment">{comment}</p>
{if:else}
<p class="other-comment">{comment}</p>
{/if}

{
/exp:group_comment}

You will need to find out the group_id=“1” parameter number for yourself by going to :

Admin->Members and Groups->Member Groups

Note down the Group ID of the admin group and use that number in the parameter. It may be the case that your admin group is 1 so you won’t need to change anything.

See if that works and I am going to add this into the plugins forum too.

Hope that helps?

Best wishes,

Mark

File Attachments
pi.group_comment.php.zip  (File Size: 2KB - Downloads: 61)
 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 24 June 2008 07:10 AM   [ Ignore ]   [ # 6 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6543
Joined  04-15-2006

Plugin thread now added!

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 24 June 2008 10:46 AM   [ Ignore ]   [ # 7 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6543
Joined  04-15-2006

Hi Igor,

Just wondering if the plugin had been of any use at all?

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 25 June 2008 03:21 AM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  7
Joined  02-10-2008
Andy Harris - 24 June 2008 06:58 AM

What’s the result if you write the value of each author_id to the screen? As in:

{exp:comment:entries weblog="tinblog" sort="asc" limit="20"}
{author_id}
<br />
{/exp:comment:entries}


It gives 1 on all comments :(

Profile
 
 
Posted: 25 June 2008 03:30 AM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  7
Joined  02-10-2008
Mark Bowen - 24 June 2008 10:46 AM

Hi Igor,

Just wondering if the plugin had been of any use at all?

Best wishes,

Mark

Thanks for your help so far guys smile
I think that the problem must lay somewhere else in the page code since no matter what method I use EE interprets all comments as from user 1.
I am pasting now most of the page code (the relevant part) since I am sure a trained eye will spot an error somewhere wink

{exp:weblog:entries weblog="tinblog"}

<div class="post_date_large"><img src="{avatar_url}" width="{avatar_image_width}" height="{avatar_image_height}" alt="{author}'s avatar" class="post_author"/>              
              <
p>{entry_date format=' %l, %F %d, %Y '} by: <a href="#">{author}</a><br> filed under: <a href="#">{categories}<a href="{path=site_index}">{category_name}</a>{/categories}</a></p></div>

<
div class="post_title"><h2><a href="#">{title}</a></h2></div>
{post_picture_main}
<p><span class="postText">{extended_post}</span></p>

</
div><div class="linepost_share"></div>
<
div class="social">            

<!--
AddThis Button BEGIN -->
addthis_pub  = 'ijurisic';
<
a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s9.addthis.com/button1-share.gif" width="125" height="16" border="0" alt="" /></a>
<!--
AddThis Button END -->

<
a name="anchor" id="anchor"></a>
<
div class="linepostComments"></div>

{exp:comment:entries weblog="tinblog" sort="asc" limit="20"}
<div class="comment">

{exp:group_comment member_id="{author_id}" group_id="1"}
{if belongs_to_group}
<div class="comment_tins">
<
img src="{avatar_url}" width="{avatar_image_width}" height="{avatar_image_height}" alt="{author}'s avatar" class="avatar">
<
div class="comment_data"><span class="username">{name}</span> | {comment_date format=" %l, %F %d, %Y "} at {comment_date format="%h.%i %a"}</div>
<
p>{comment}</p></div>
{if:else}
<div class="comment_all">
<
img src="{avatar_url}" width="{avatar_image_width}" height="{avatar_image_height}" alt="{author}'s avatar" class="avatar">
<
div class="comment_data"><span class="username">{name}</span> | {comment_date format=" %l, %F %d, %Y "} at {comment_date format="%h.%i %a"}</div>
<
p>{comment}</p></div>
{/if}
{
/exp:group_comment}

<div class="comment_divider"></div>
</
div>

{/exp:comment:entries}

<div class="linepost_your"></div>


{exp:comment:form weblog="tinblog"}

<div class="comment_form">

{if logged_out}

<p>Only registred users may post comments!</p>

<
p>Please Log in or <a href="{path=member/register}">Register</a>.</p>

{/if}
{if logged_in}
<p><textarea name="comment" cols="63" rows="6" class="textarea">{comment}</textarea></p>

<
p><input type="checkbox" name="notify_me" value="yes" {notify_me}/> Notify me of follow-up comments?</p>

<
input type="image" name="submit" class="submit_post" src="{site_url}images/interface/building/post/post-button.gif"/>
{/if}
</div>

{/exp:comment:form}


{
/exp:weblog:entries}

Sorry for such a long post.

Profile
 
 
Posted: 25 June 2008 03:31 AM   [ Ignore ]   [ # 10 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6543
Joined  04-15-2006

Did you try my plugin Igor? wink

Best wishes,

Mark

P.S. for information it would be the {entry_author_id} variable that would give you a different id each time, the {author_id} variable is literally for the id of the person who posted the entry not to do with comments. Using the {entry_author_id} would not be much use to you on its own though as you want to be able to style differently depending on a certain group. That is where my plugin should hopefully help you out! wink

Let me know how it goes won’t you?

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 25 June 2008 03:33 AM   [ Ignore ]   [ # 11 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6543
Joined  04-15-2006

Oops sorry just noticed your post after I had posted mine. So using my plugin what does happen?

You should find that if you use it as per the instructions that anyone in the group_id of 1 will have their comments styled differently to all others. Have you actually got any comments posted that are from different groups to be able to test this out?

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 25 June 2008 03:36 AM   [ Ignore ]   [ # 12 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6543
Joined  04-15-2006

If you try this code (code I was using to test this out on a stock install of 1.6.3) and ensure that you have some comments by the super admin group (I guess is still group 1) and also log out and post some comments via other users who aren’t in the admin group and also some guest posts and see if it does what you are expecting it to do. You can then style it up as appropriate.

{exp:comment:entries weblog="{my_weblog}" limit="25"}

{exp
:group_comment member_id="{author_id}" group_id="1"}
{if belongs_to_group}
<p>This comment was made by someone in the Super Admin group</p>
<
p>{comment}</p>
{if:else}
<p>This comment was made by someone else!!</p>
<
p>{comment}</p>
{/if}
{
/exp:group_comment}


{
/exp:comment:entries}

See if that helps.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 25 June 2008 03:39 AM   [ Ignore ]   [ # 13 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6543
Joined  04-15-2006

Also as a quick note, you shouldn’t be nesting the comment tag pair within the weblog tag pair as that will cause things to go wrong wink

If you fix that up and then use the code I showed above you shouldn’t have a problem hopefully.

Hope that helps.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 25 June 2008 05:44 AM   [ Ignore ]   [ # 14 ]  
Summer Student
Total Posts:  7
Joined  02-10-2008

Works like a charm! smile

The nested tag was the cause of all problems.
Your pluggin works perfectly.

Thank m8!

Profile
 
 
Posted: 25 June 2008 05:58 AM   [ Ignore ]   [ # 15 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6543
Joined  04-15-2006

No problem at all. Glad it is working as it was written very very quickly yesterday. It is a very simple plugin though so should just work a charm. Have used it now on a couple of sites that I am building too so thanks for requesting it in a round-about sort of way!! wink

When I get the time I will probably update the plugin so that it also handles more than one group. Might be nice if you say have more than one admin group and you want all the staff members of a site to look different to that of other peoples. Will probably add that in at some point as well.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
   
 
 
‹‹ Recent Comments      Events Calendar ››
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64909 Total Logged-in Users: 44
Total Topics: 81854 Total Anonymous Users: 29
Total Replies: 440068 Total Guests: 226
Total Posts: 521922    
Members ( View Memberlist )