Hi,

I'm not quite sure if this is the correct place, but perhaps you can help.

In version 5.x, to show a little star * next to a specific role in my template.php was the following:

function phptemplate_username($object) {
   $user = user_load(array('uid'=>$object->uid));
   if (in_array('Platinum Member', $user->roles)) {
      return theme_username($object) . '<img src="http://www.mysite.com/star.gif">';
   }
   return theme_username($object);
}

I've now added the same to the Drupal 6.x template.php, but does not seem to show the little * :)

No errors, and wondering if this should rather be added to the realname.module or is it perhaps in conflict?

Would most appreciate any help to make this work.

Look so forward to any reply,.
Lilian

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Liliplanet’s picture

bump * sorry *

NancyDru’s picture

Status: Active » Postponed (maintainer needs more info)

The RealName module overrides the theme registry so I don't think "phptemplate_username" would be called. You will need to hack "realname_theme.inc" with your change.

But better yet, perhaps, is that you send me a copy of your star.gif and let's see about perhaps making this a standard feature.

Liliplanet’s picture

FileSize
170 bytes

That is tremendous, thank you Nancy ...

Well, the little * star * is small, but defines the privileged members to others :) in my case Platinum Members.

If not the star, perhaps to change username by role to a specific color?

Please find attached the little * star *.

Look so forward and thank you.
Lilian

NancyDru’s picture

Check the pics:

Content display

Admin

Liliplanet’s picture

Wow Nancy! That looks fantastic! Will this be released with your fabulous RealName.module? Still hoping for a visit from you ..

NancyDru’s picture

Status: Postponed (maintainer needs more info) » Fixed

Committed to 6.x only.

roball’s picture

FileSize
3.55 KB

This is really a cool feature! Just wanted it to try out. As shown on the attached screenshot of the role edit page, I have a "User level image" text field. How must I point to the image there?

Thanks,
rob.

BTW, how did you manage to display the attached images in your post?

NancyDru’s picture

You specify a path (I am updating the description) relative to your current files path. The image will be shown when you theme the username, unless the specific theme call turns it off (it is on by default).

Liliplanet’s picture

Hi Nancy! Thank you so much for this wonderful feature ..

Nancy, I've just downloaded latest (10 March) and adding 'star.gif' to 'user level image' field, but it does not seem to save.

I've uploaded the star.gif to sites/default/files ..

Look forward to hearing from you, and again thank you.
Lilian

roball’s picture

Same problem here. I just updated the RealName Module to 6.x-1.x-dev (2009-Mar-10), went to admin/user/roles/edit/3 and specified role_pics/3.png at the "User level image" field. After clicking "Save role", realname_user_level_3 => 'role_pics/3.png' appeared in the info box, but no image has been displayed in the "User level" column. Going to admin/user/roles/edit/3 again showed the "User level image" field to be empty.

NancyDru’s picture

FileSize
42.33 KB

My file directory is "files/d6" and that is where my images are.

As you can see mine are saving. Can you check the HTML output, please?

Note this is not an upload; the images must be there first.

NancyDru’s picture

FileSize
17.82 KB
NancyDru’s picture

FileSize
17.82 KB

trying again

roball’s picture

Yes, I have manually created the "role_pics" directory under the directory stated on the field's description (sites/default/files) via SFTP and uploaded the "3.png" file there, so its path is sites/default/files/role_pics/3.png. I can also successful view this image directly by calling its URL in my browser. I am using the default (Garland) theme for this test, if this should make any difference.

NancyDru’s picture

I don't recall having to clear the cache, but have you tried that? And can you view the HTML source to see what it is producing?

roball’s picture

After clearing the cache (via the "Development" block from the "devel" module), I tried again what I've described in reply #10, with the same result (no image). The HTML code of the row in question is:

<tr class="even"><td>Role 3</td><td></td><td><a href="/drupal/admin/user/roles/edit/3">edit role</a></td><td><a href="/drupal/admin/user/permissions/3">edit permissions</a></td> </tr>
Liliplanet’s picture

Hi Nancy,

Sorry, I still seem to be having the same problem.

I select 'edit role', add 'sites/default/files/role_pics/star.gif' (role_pics created as a folder), but it firstly does not save the field or show the image ..

empty cache and html as follows:

<tr class="even"><td>Platinum Member</td><td></td><td><a href="/admin/user/roles/edit/4">edit role</a></td><td><a href="/admin/user/permissions/4">edit permissions</a></td> </tr>

Could it perhaps be something with my theme that is causing this?

Look forward to your reply, and thank you.
Lilian

NancyDru’s picture

Based on what roball reported, I am not surprised that you are still seeing it. Clearly, the image tag is not being built.

Well, I was going to have you do lots debugging, but I see the problem. I had the save code commented. Don't ask me why.

Go to function _realname_role_submit and uncomment line 528 (variable_set).

NancyDru’s picture

I committed that fix.

Liliplanet’s picture

FileSize
20.6 KB

Hi Nancy,

Wow, that's beautiful! Makes such a difference .. Thank you so much!

Attached image :)

NancyDru’s picture

Fabulous, thanks for sharing.

roball’s picture

I can also confirm that this nice bonus feature of RealName now works well. It seems that the current dev branch is now mature enough to get rolled out as a new release - what do you think, Nancy?

NancyDru’s picture

NancyDru’s picture

Status: Fixed » Closed (fixed)
tclusellas’s picture

FileSize
27 KB

Hi Nancy,
First of all, thank you for your fantastic module and support that you provide.
This module is exactly what I was looking for to add to my forums.

I'm trying to have an image displayed for roles, unfortunately I can't get it to work properly.
I followed your above instructions without success.
I can see a question mark next to the role (see photo) but not the image.
I checked permissions to 777 but still nothing.
Neither can I see the image in my browser (mysite.sites/default/files/admin.jpg) I get page not found.

I'm using d6.13 and RealName 6.x-1.x-dev.

Do I need to change the:
" function _realname_role_submit and uncomment line 528 (variable_set)."
I couldn't find where it is.

It must be something simple, but after two days trying, I decided to ask for help.

Look forward to your reply, thank you.

Tomas

tclusellas’s picture

Dismiss the above post,
After cleaning every possible cache.
I can report that is finally working well for me.

Thank you again.

Tomas

browlands’s picture

Title: Add image to specific role » Add image to specific role - Site wide settings

Would be nice to have an additional feature to describe the real username, user level picture and date output without hacking the code.

From an immediate standpoint can anyone help me modify the realname_theme.inc file (presumably) to show ...

user level image | realname | date

rather than

realname | user level image | date string

at present. I'd be very pleased if someone could provide a patch or some code below.

For the additional feature I suggest some additional settings as follows: -

[order] [prefix] [level image] [suffix] [hide check]
[order] [prefix] [real name] [suffix] [hide check]
[order] [prefix] [submitted] [suffix] [hide check] [php date format]

where ...

order is a dropdown 1-3, to allow the variables to be displayed in various sequences
prefix is any user configurable string or null
suffix is any user configurable string or null
hide check removes that particular element from displaying
php date format allows for various date formating options.

This would give bountiful options on theming the output without having to resort to a hack.

browlands’s picture

Check current picture, user level | realname | date would be more visually appealing.