Hiya,
I made this plugin exceptionally quickly in reply to a thread here.
Igor wanted a way to be able to style comments from a certain group differently to everyone elses.
This plugin should hopefully address that need. Whilst it is possible to style the original entry authors comments differently (scroll down to see my method 😉 ) this plugin allows you to style all members of a certain group differently.
Usage Instructions :
CSS Code
.group-comment {
text-transform: uppercase;
}
.not-a-group-comment {
text-transform: lowercase;
}
Obviously the CSS can be anything you need and you can use DIVs and anything else that you like in between the conditional shown below to lay out your comments just the way you want them
ExpressionEngine Code - Goes inside {exp:comment:entries} tag pair
{exp:group_comment member_id="{author_id}" group_id="1"}
{if belongs_to_group}
{comment}
{if:else}
{comment}
{/if}
{/exp:group_comment}
Hope that helps someone somewhere. As mentioned before this was written in about 2 minutes so hopefully should work 😉
Best wishes,
Mark
Mark,
Good contribution! Couldn’t this work already? By running a conditional like so:
{if group_id != "1" AND group_id != "6"}
Regular Comment
{if:else}
Super Admin / Editor group Comment
Managed to get it to work, but took me time to figure out to use an AND rather than a OR.
Well that’s just not fair if it does work as I couldn’t see a group_id anywhere in the comment entries variables tag pair listed in the documents :down:
I just did a really quick cursory test and it seems as though what you have there does work! All my time wasted making the plugin due to either something missing in the documents or me not looking properly?
I may still be wrong as it was a really quick test though.
Sheesh am I going to be upset if I did all that just to find out there is a group_id variable that I have missed somewhere!!!
Best wishes,
Mark
The {group_id} appears to return the group id of the currently logged in user, not the group id of the comment’s author. For some reason, the comments module doesn’t return the comment author’s group id.
I took the liberty of updating this plugin to support multiple groups. So, if you want to check if an author is a member of one of three groups you could do something like this.
{exp:group_comment member_id="{author_id}" group_id="1|6|8"}
{if belongs_to_group}
I am in one of these groups!
{if:else}
I am not in one of these groups.
{/if}
{/exp:group_comment}
Beware that this plugin adds a sql query for every comment on the page. Turning on caching for that template will help.
The problem with this plugin seems to be that both group_id and author_id default to the post’s author_id and group_id when the comment is made by non-member. Anyone have any ideas on how to work around that issue?
It seems that the comment:entries tag should really have completely separate variables for these like comment_author_id and comment_group_id. It would be a good FR, but in the meantime, it seems I have no way to differentiate member and non-member comments… I really wanted all of our members to be able to reply as a common voice - so guest comments would show their name and anyone in specific member groups would be able to reply as “The Company”.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.