Is there a way to display a country flag with location module?
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:
sites/{default}/files
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; ?>
cool. thanks!
Chris
how would I get to a node referenced cck location field?
Automatically closed -- issue fixed for 2 weeks with no activity.
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) :
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;
endforeach;
endif;
Does this work with views?
works with d7?
Comments
Comment #1
ratebz commentedComment #2
mohammed j. razemHey, 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}/filesfolder, and add this code into yournode.tpl.php:Comment #3
mohammed j. razemComment #4
socialnicheguru commentedcool. thanks!
Chris
how would I get to a node referenced cck location field?
Comment #6
stefanhapper commentedAttention: 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) :endforeach;endif;Comment #7
BeaPower commentedDoes this work with views?
Comment #8
BeaPower commentedworks with d7?
Comment #9
BeaPower commentedComment #10
legolasbo