Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
Firstle, do not edit any of the files that came with the module! You should override the theme function in your theme. Open up your themes template.php file and copy and paste the above code. Rename the function from 'theme_ip2cc_flag' to 'name-of-your-theme_ip2cc_flag' (where name-of-your-theme is the name of your theme!). Refresh your theme registry (visiting the /admin/build/theme page should be enough to do that). Now, you can edit your new function as you need to and it will override the one from the module. For more infor about overriding theme functions, see http://drupal.org/node/55126
Wow! unbelievable! I learned so many things from your last post, it's amazing!!
THANK YOU THANK YOU THANK YOU!! for the speed and accuracy of your help.
I suppose all functions (from other modules) can be used the same way, so we don't have to edit the actual modules themselves.
That's another great feature of working with Drupal. I am learning as I go and love it so far. Can't do without the help of people like you though.
thanks mrfelton, can you please check the helpful code you had sent above as how to also display the country name? Currently it only displays from {flag}, would like to have from{flag}{country name}, if possible.
on the last line of your code $cc->country_name; is always blank.
Comments
Comment #1
mrfelton commentedYou can do this by overriding the function theme_ip2cc_flag()
Comment #2
vako commentedThanks for the reply. I would appreciate if you can provide a little bit of guidance in doing so please.
So far I have located the file - \ip2cc\contrib\ip2cc_node\ip2cc_node.module
and the section is:
Which lines can I replace with what to be able to get the following output:
from {flag} {country name}appreciate your help!
Comment #3
mrfelton commentedFirstle, do not edit any of the files that came with the module! You should override the theme function in your theme. Open up your themes template.php file and copy and paste the above code. Rename the function from 'theme_ip2cc_flag' to 'name-of-your-theme_ip2cc_flag' (where name-of-your-theme is the name of your theme!). Refresh your theme registry (visiting the /admin/build/theme page should be enough to do that). Now, you can edit your new function as you need to and it will override the one from the module. For more infor about overriding theme functions, see http://drupal.org/node/55126
To get thhe output you desire, this should do it:
Note: All I did here was alter the last couple of lines.
Comment #4
vako commentedWow! unbelievable! I learned so many things from your last post, it's amazing!!
THANK YOU THANK YOU THANK YOU!! for the speed and accuracy of your help.
I suppose all functions (from other modules) can be used the same way, so we don't have to edit the actual modules themselves.
That's another great feature of working with Drupal. I am learning as I go and love it so far. Can't do without the help of people like you though.
Thanks again.
Comment #5
mrfelton commentedGlad you got there in the end :)
Comment #6
vako commentedI come again with two issues and seek your help please.
A) the Canadian and US flags are not showing, the $cc code is 'unknown'
B) am unable to extract the country name, only the flag.
would appreciate your input on this please. thanks!
Comment #7
mrfelton commentedThere have been other reports of US IP addresses not working anymore. Please see #579632: Database not currently supporting IP ranges it once supported
Comment #8
vako commentedthanks mrfelton, can you please check the helpful code you had sent above as how to also display the country name? Currently it only displays
from {flag}, would like to havefrom{flag}{country name}, if possible.on the last line of your code
$cc->country_name;is always blank.thanks.
Comment #9
mrfelton commentedHave you got the countries_api module installed? This module makes extra information, including the country name available.
Comment #10
vako commentedI solved it by changing the line to:
return 'from '.$icon.' '. "$country->country_name";thanks again.
Comment #11
mrfelton commentedAh yes, good catch.