Hi there!
First, great module, was exactly what I was looking for! Plus, the user levels functionality you added, while not exactly what I needed, did point to solving another request from my client.
I was wondering if it would be useful for this module to add in some CSS classes to the realname_theme() function, so that themers could target them, instead of having to upload images.
I think you would only need to do something like the following in realname_theme(), after the image code (starting after line 82 in realname_theme.inc)
// Format user levels as css here
foreach ($object->roles as $rid => $role) {
// Make a nice css value out of the role title
$l_opts['attributes']['class'] = preg_replace("/[][\\`~!@#$%^&*(){}:;<>,.?\/_|\s-]/","",strtolower($role));;
}
For better CSS readability, might want to break this into two lines, removing special characters first, and then replacing spaces with a dash:
// Format user levels as css here
foreach ($object->roles as $rid => $role) {
// Make a nice css value out of the role title
$l_opts['attributes']['class'] = preg_replace("/[][\\`~!@#$%^&*(){}:;<>,.?\/_|\s-]/","",strtolower($role));;
}
Seems to work for me....thoughts? I couldn't quite figure out another way to add classes while using your module at the same time, since you override theme_username().
Using:
RealName v1.3
Drupal 6.16
Comments
Comment #1
Stephen Scholtz commenteder...forgot that users can have multiple roles...code should be:
...and...
...and one too many semicolons in there too.
Comment #2
nancydru"Needs review" indicates that an actual patch is attached.
BTW, http://api.drupal.org/api/function/form_clean_id/6 might be better than preg-replace.
Comment #3
nancydruCommitted to 6.x-1.x-dev.
Comment #4
Stephen Scholtz commentedNice, thanks for pointing me at form_clean_id, another tool in my belt. :) And I'll use "needs review/active" correctly next time. Cheers!
Comment #5
Stephen Scholtz commentedChecked out the dev version of the module and saw your change. Thanks!
However, the class addition doesn't seem to be catching all the time. For example, the classes don't show up in the "Who's Online" Block unless the line that puts in the classes is outside of the if/else check...
Original...
Tweaked...
Pretty sure this is because I'm not using any images for my user levels, so $roles[$rid] ends up being set to nothing.
Comment #6
hass commented