By liliplanet on
Hi,
I've done an extensive search, but don't seem to come up with a solution.
Is it possible to have a little star (image) next to a specific user role (weight)? Basically in my views I would like to define Platinum users by a little star to show visitors that they have a full profile.
Any help would be most appreciated.
Lilian
Comments
you may have to work with
you may have to work with your themes files to achieve this depending on where exactly you want to display the little star. Assuming you want to display the star next to the user name do the following in your template file. This will display a star next to wherever the username is displayed..
The exact code will change based on where you are thinking of displaying your star.. If you wish to only display this on the profile page i.e. when you go to http://www.mysite.com/user/ then you will need to create a theme for the user page and add code like the above in it at the appropriate location.
Thank you so much for your
Thank you so much for your reply Panis.
I've tried platinummembers as the role is called Platinum Members ...
function phptemplate_username($object) {
';
$user = user_load(array('uid'=>$object->uid));
if (in_array('platinummembers', $user->roles)) {
return theme_username($object) . '
}
return theme_username($object);
}
but nothing happening this side. Is it also perhaps possible to use field_name instead of username although username would be fantastic.
Most most appreciate your help.
Lilian
where exactly do you need
where exactly do you need the start to appear - do you have a screenshot - maybe the location yuo want the image to appear is not where the username is being displayed.
So much appreciated, please
So much appreciated, please see http://www.filmmaker.co.za/planet/member_directory.php
Would like to have the * (start) next to the username, also it would be great that where the username appeared anywhere on the site to show the star next to Platinum Members.
So kind .. thank you.
Lilian
what are you using to
what are you using to generate this directory?
Is that a view? if so where are you pulling the author name from? if that is not the standard node author for the profile node name then the mechanism I described to you will not work. If this is custom code used to generate the table then you need to update the custom code to include the '*'.
Hi Panis, Thank you for your
Hi Panis,
Thank you for your reply. Panis, yes it is in views, but would like it throughout the site next to the username everywhere as well.
I had to create a 'authorship' field as doing an import through the node import module saved as 'author' user/1 or admin
Is it possible to have the * next to a node_field ie field_name? but just username throughout the site would be wonderful.
What I'm trying to do is have Platinum Members appear different to normal users in the views. Some way to differentiate the members.
Look forward to your response, and again, thank you Panis.
Lilian
not an easy fix then...
not an easy fix then...
Options:
a) update the author for each of these items to the actual user - this will have other implications because now they can edit their own profiles - however you could disable "edit own " through permissions - if you do not want that to happen.
If you have access to mysql you can do this via: (take a backup of the database before you do this)
replace profile_table with the cck table name (something like content_type_profile_table) and the authorship field name with the appropriate field name in the table - usually it is of the form field_authorship_value
if you have table prefixes in your drupal settings then you will need to prefix the table names appropriately.
This should reset the username field to the actual user and then in the view display the "Node: Author name".. Now override the username theme with the code snippet I gave you and it should work..
You could also resort to updating the authorship field to have a star in the end through mysql commands based on which of these users are platinum members. Anywhere in your site now instead of displaying "authorship" field now display the "Node: Author field" and things should work as you want them to.
b) this is a very different approach with no table changes.. You will need to override the theme of the table.. in your template.php file copy paste the theme_views_view_table function from the views.module file. rename the function to: phptemplate_views_view_table_machine_name_of_view_here()...
Now you know that the first field that is being generated in the code is the authorship field - use that to figure out the role for the user and print a * next to it..
This is not as flexible as option (a) but you do not have to mess around in the databases.
...
Panis, as always, you have thorough answers!
:-)
(I wonder why she has three names associated with a row. perhaps she should use several userreferences.)
...
No, you must type 'Platinum Members' there. Not 'platinummembers'.
Panis' code should work.
Yes! All is good and the the
Yes! All is good and the the * appears!
Panis, just a small thing (I hope) .. the image appears after the username*, is it perhaps possible to have it before the *username. I think it would just look prettier.
Thank you so much for your support.
Lilian
just change the code to
just change the code to reorder where the
<img src=...> or *is in the print function call - and thanks to moofie for pointing out the correct role to use.mix 2 objects in phptemplate_username
Hi Mooffie and Panis,
Thank you so kindly for helping me a couple of weeks ago. Please, I now have 2 objects that I would to include in the phptemplate_username
your fabulous script:
and username to first name and last name:
I really have tried to somehow put them together, and only get one to work at a time :)
Please Mooffie and Panis, would you be so kind to show the in the right direction?
Look forward to your reply.
Liilan
rename the second function
rename the second function to something else.. e.g.
and replace calls to theme_username() in the first function to call mytheme_firstlastname_theme()
make sure that your first function has the signature phptemplate_username($object, $links) just like the second one and pass the $links variable on to the mytheme_firstlastname_theme()..
thank you Panis
Thank you for your super-fast reply.
I've tried changing username to starname and do not receive errors :), but then again, do not see the star * either .. is this not correct? so sorry, have very little experience with templating.
See second function lower down the page ...
You mention mytheme in your reply ... my theme is called zen_planet. Sorry Panis, quite lost here.
Look forward to your reply and again, thank you so much.
Lilian
2 Options below not knowing
2 Options below not knowing exactly your requirements
Option 1 - replace the last two functions with
Option 2 - If you want to make the username show with a star everywhere then you will need to flip it around
thank Panis
Sorry Panis still getting the error when selecting your second option (in other words for the star to appear everywhere)
Fatal error: Cannot redeclare phptemplate_username() (previously declared in template.php:186
I tried replacing phptemplate_username with fullname, but got the same error.
Thank you Panis, and look forward to your reply.
Liilan
a) The very first line of
a) The very first line of the code you posted - rename the function to phptemplate_fullname.
b) the function immediately after that is a blank function that you misunderstood my instructions - delete that function..
thank you Panis
Panis, I'm really starting to feel quite blonde here and apologize for not getting this. I've tried everything and still get errors.
Currently the error is : warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/mysite/themes/zen_planet/template.php on line 196.
Please, I can imagine it's in there, but honestly have moved, changed, renamed and :) doesn't work.
Would most appreciate your kind help again. Thank you Panis.
in the function below - the
in the function below - the object being passed in may not be a real object sometimes - which would make the in_array function get a null parameter and hence your error.
Look at how the phptemplate_fullname() function handles this and you can add the same check. This should help fix the error you are seeing.
still no *
Hi Panis,
Can you believe that I'm still trying to make this work (since May ..:) and was hoping I'd figure it out eventually ...
I've moved stuff, replaced, deleted, added and receive 'Fatal error: Call to undefined function theme_fullname() in /home/mysite/public_html/sites/all/themes/bluebreeze/template.php on line 97'
With the following it works, but no 'star *' next to the Platinum Member.
Please Panis I'm prepared to pay for your help, if you be so kind to figure this out. It's pretty important to define my members in their roles.
Look forward to hearing from you, and thank you.
Lilian