Hey, is it possible to change the background color of a single comment depending on the user role of the author?
I think of a if clause, which checks the author of each comment and allocate the comment field a different css class. So user can identify comments from specific user faster and easier.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- mhauptma@mhauptma
mhauptma - 0 likes
- Cash@costelloc
Cash - 0 likes
- mhauptma@mhauptma
mhauptma - 0 likes
- Matt Beckett@Beck24
Matt Beckett - 0 likes
- mhauptma@mhauptma
mhauptma - 0 likes
- Matt Beckett@Beck24
Matt Beckett - 0 likes
- This Script Lover@elgglover
This Script Lover - 0 likes
- This Script Lover@elgglover
This Script Lover - 0 likes
You must log in to post replies.Nobody? A general comment wheather this is MAYBE with X effort possible or forget it and wait for the new milestone with comment as an entity :D would be helpfull too!!!
Yes, it can be done with a plugin. As you said, a css class could be added to the div for the comment and then themers could use whatever colors they want. This sounds really easy to add.
Thanks! I'm new to elgg so where should i start? I know that the the replies.php file in groups/views/default/discussion shows the discussion. In line 17 the comments are listed with the elgg_list_annotations, so i guess i should edit this method. But this would bring some side effects or?
The best place to start is by reading this page: http://community.elgg.org/pages/view/880143/dont-modify-core
Followed by learning about the elgg views system: http://docs.elgg.org/wiki/Engine/Views
What you want to do is find the view that outputs the comment, and extend/overwrite/hook it in a new plugin. Your new view will be the same as the old view, but it will check for whatever user status you require and assign the appropriate classes.
Thanks! After some days of reading and coding, i did it. With the help of CSS3 i made a nice color gradient *yeah* ^^.
@Matt First i thought, why he can't just write a soluation or a helpful code snippet. But now i think, thanks dude! This was the kind of help i needed to better understand the elgg platform and to get the skills to develop my own plugins (like this one)!!
You're welcome! And it will only get easier.
@mhauptma, would you please upload your plugin to the community?
Would like to test it, sounds like a good idea.
Thanks
@mhauptma, what are you using to differentiate different roles?
I folowed instructions from Roles plugin but not even showing available roles
Here is my code:
$user = elgg_get_logged_in_user_entity();
$user_guid = $user->getGUID();
//$myrole = roles_get_role($user = null);
//$myrole = roles_get_role($user);
$myrole = roles_get_role();
echo 'Role:' . $myrole . '';
I need to do what you said you got it to work, show something if user has certain role. Can you share some info on how you did it ?
Thanks.