By Paul Knierim (WSN PHP Scripts)
03/28/09 (Edited 12/12/11)
Suppose you want a flag icon to mark which country a listing is in. Download the flags collection at the bottom of this article. Extract the zip and upload the flags directory from it to /templates/images_default so that it becomes templates/images_default/flags (or images_yourthemename for other themes). Then create a listingflags.php file with this content:
<?php
$pseudomethods[] = 'countryflag';
function countryflag($object)
{ // return flag image
global $settings;
if ($object->country) $flagimg = strtolower(getcountrycode($object->country));
if ($flagimg && file_exists($settings->imagespath().'/flags/'.$flagimg.'.png')) $ret = '<img src="{IMAGESURL}/flags/'.$flagimg.'.png">';
else $ret = '';
return $ret;
}
?>
$pseudomethods[] = 'countryflag';
function countryflag($object)
{ // return flag image
global $settings;
if ($object->country) $flagimg = strtolower(getcountrycode($object->country));
if ($flagimg && file_exists($settings->imagespath().'/flags/'.$flagimg.'.png')) $ret = '<img src="{IMAGESURL}/flags/'.$flagimg.'.png">';
else $ret = '';
return $ret;
}
?>
Save that in your /modifications/ directory (if the directory doesn't exist, create it). You can now use {LINKCOUNTRYFLAG} in your templates to display the flag. You'll probably want to put it in the listing bit template (Admin Panel -> Templates -> Manage Templates -> Subtemplates -> Listing Bit).




