Is there a way to display a country flag with location module?

Comments

ratebz’s picture

Component: User interface » Miscellaneous
Category: feature » support
mohammed j. razem’s picture

Hey, I've done this before.
Just download a flags pack, see http://www.ip2location.com/flagsoftheworld.aspx

The filenames are in ISO 3166. Copy the flags images folder into sites/{default}/files folder, and add this code into your node.tpl.php:

<?php if ($node->location['country']): ?>
<div class="country-flag">
<?php $flag_path = file_directory_path() . '/flags/' . $node->location['country'] . '.png'; 
      print theme('image', $flag_path, $node->location['country_name'], $node->location['country_name']); ?>
</div>
<?php endif; ?>
mohammed j. razem’s picture

Status: Active » Fixed
socialnicheguru’s picture

cool. thanks!

Chris

how would I get to a node referenced cck location field?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

stefanhapper’s picture

Attention: file ending for the images is .gif, not .png

+ this is the code that needs to be inserted when you use CCK location (which also works for multiple countries):

(replace every mention of "field_country" with your field_name used for the CCK location field)

if ($node->field_country) :
foreach($node->field_country as $country) :

 $flag_path = file_directory_path() . '/flags/' . $country['country'] . '.gif';
			  print theme('image', $flag_path, $country['country_name'], $country['country_name']);
			  print t($country['country_name'])

endforeach;
endif;

BeaPower’s picture

Does this work with views?

BeaPower’s picture

works with d7?

BeaPower’s picture

Status: Closed (fixed) » Active
legolasbo’s picture

Issue summary: View changes
Status: Active » Closed (fixed)