This thread is a discussion for the wiki article: Style Comments by Author
   
1 of 2
1
Style Comments by Author
Posted: 22 June 2008 02: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 01:42 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
RankRankRank
Total Posts:  354
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 04:10 AM   [ Ignore ]   [ # 2 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13726
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 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 24 June 2008 06: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 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 07:58 AM   [ Ignore ]   [ # 4 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1165
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

Profile
 
 
Posted: 24 June 2008 08:03 AM   [ Ignore ]   [ # 5 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13726
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}
<class="admin-comment">{comment}</p>
{if:else}
<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: 336)
 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 24 June 2008 08:10 AM   [ Ignore ]   [ # 6 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13726
Joined  04-15-2006

Plugin thread now added!

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 24 June 2008 11:46 AM   [ Ignore ]   [ # 7 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13726
Joined  04-15-2006

Hi Igor,

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

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 25 June 2008 04:21 AM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  7
Joined  02-10-2008
Andy Harris - 24 June 2008 11: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 04:30 AM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  7
Joined  02-10-2008
Mark Bowen - 24 June 2008 03:46 PM

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><brfiled 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 04:31 AM   [ Ignore ]   [ # 10 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13726
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 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 25 June 2008 04:33 AM   [ Ignore ]   [ # 11 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13726
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 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 25 June 2008 04:36 AM   [ Ignore ]   [ # 12 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13726
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 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 25 June 2008 04:39 AM   [ Ignore ]   [ # 13 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13726
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 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 25 June 2008 06: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 06:58 AM   [ Ignore ]   [ # 15 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13726
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 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 11 February 2009 09:33 PM   [ Ignore ]   [ # 16 ]  
Summer Student
Total Posts:  11
Joined  07-17-2007

For those having problems making {member_group} return anything but ‘1’ in their {exp:weblog:comments} tags, use {group_id} instead. {member_group} is meant to return the group # of the logged-in user; there’s just a typo in this article. Hope this saves somebody some time smile

Profile
 
 
Posted: 09 March 2009 12:34 PM   [ Ignore ]   [ # 17 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  105
Joined  04-19-2008
dndrnkrd - 12 February 2009 02:33 AM

For those having problems making {member_group} return anything but ‘1’ in their {exp:weblog:comments} tags, use {group_id} instead. {member_group} is meant to return the group # of the logged-in user; there’s just a typo in this article. Hope this saves somebody some time smile

Ditto. Corrected now though wink

 Signature 

XILO Communications Ltd.
w: http://www.xilo.net/

Profile
 
 
Posted: 11 March 2009 10:40 AM   [ Ignore ]   [ # 18 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2523
Joined  02-28-2008

This worked ok for me:

{if entry_author_id == author_id}
        
<div class="comment_author">
        
{if:else}
         
<div class="{switch="comment|comment_alt"}">
        
{/if} 

This way you have an alternative css for regular comments and author gets their own style.

 Signature 

Defeat is a state of mind; no one is ever defeated until defeat has been accepted as a reality.

Profile
 
 
   
1 of 2
1
 
‹‹ Recent Comments      Events Calendar ››