I've been searching all over Drupal for the answer to this one.
When my users sign up I want them to choose the country that they are based in. I have set up a 'country' field in the user profile following this:
What I would like is for the appropriate flag to show up with the country name. I have downloaded flags from http://www.famfamfam.com/lab/icons/flags/
I would then like this flag to show up both in a user's comments and on their profile page when other users click on their profile.
I have tried IP to Country http://drupal.org/node/45806 but this doesn't give you the option to show the country on the profile page and I don't want to show the country of the IP but rather the country the user themselves select since they travel a lot (e.g. a user may be normally stationed in Kenya but be on holiday in the UK. I want their flag to remain 'Kenya' even if they post something while in the UK).
I have also tried the location module http://drupal.org/project/location but that doesn't seem to allow to you to show a country flag.
Help!
Comments
Sounds like something you'd
Sounds like something you'd have to program yourself... which would take working knowledge of PHP, MySQL, CSS and Drupal's internal workings. It sounds really easy to do (that's the advantage of working with something as flexible as Drupal), but... if you're a beginner at all these things, like me, it will take you plenty of work and study and trial and error.
Yep, definitely sounds like
Yep, definitely sounds like you need to customize the theme in the profile and comment template files. If the values in the field line up nicely with the names of the graphic files (ie "USA" = "usa.png"), it should be fairly simple. Check out Customising the user profile layout to get you started. Once you grasp that, theming comments will follow a similar approach.
Interesting pointer...
I think this is still a bit beyond me, though it must be quite simple as internationalisation modules and IP To Country module call up flag icons using the standard ISO two-letter country code.
Other suggestions welcome!
Old subject, but....
I know this is an old topic, but I thought i would share one easy solution for those who wish to do this.
You will need to add a new user profile field, visit:
www.yourwebsite.com/admin/user/profile
I put mine in a category called "Personal Information"
Create a new "list selection" field
Add the following:
Title: Country
Form name: profile_country
Exlplaination: Which country do you live in?
Selection options:
Make sure this is Public field, content shown on profile page and on member list pages.
Make sure the User Must enter a value
Make sure it is visible in registration field
Now, you'll need to insert the following where you want it in your custom user pages template:
Note: Now, this is not awesome, and you will have to change the Famfam fam names from their ISO names, to the ones in the list above, there is a better way (which would be to use php to convert from a DB table), i just haven't done it... All it needs is a very simple bit of php. I'll try, but would prefer a pro to do it.
Note: where we store the images: http://www.yourwebsite.com/files/image/country_flags/
Change accordingly.
Now, get some lovely icons, i recommend FamFamFam, cos he is a legend, and his icons are great:
http://www.famfamfam.com/lab/icons/flags/
This works for me, hopefully for you too.
Taking it to the next level:
List of names and ISO's
http://unstats.un.org/unsd/methods/m49/m49alpha.htm
The following website has some great code which could be the basis of this mod. I honestly reckon this should be rolled into the core of Drupal, considering it is so useful, and Drupal is global. if there are issues with Copyrights for images, I am sure there is a set available with no restrictions.
All is needed is to convert some php to read the row where we stored the table name above. The example below is taken from:
http://27.org/isocountrylist/
I'll leave that for a php guru, anhow, i reckon this is way better than using a massive ip to flag, is quicker, and is foolproof.
Any php legends who are up for it, please go for it and post back.
Cheers...
This doesn't works for Drupal
This doesn't works for Drupal 6.16 did actually the same steps as u described in this post... 72dpi, can u take a look for ur code in D6? Thanks
didn't work for me either :[
didn't work for me either :[