Image Map Area Helper
CodeIgniter, Development, Helper April 25th, 2009Today I need to have an area link within an imape map for a lot of links with in my CodeIgniter application. I can’t find a helper or function within the framework, so I wrote an area helper function:
<?php
/**
* Image Map Area Link
*
* Creates an anchor based on the local URL.
*
* @access public
* @param string the URL
* @param string the link title
* @param mixed any attributes
* @return string
*/
if ( ! function_exists('area_anchor'))
{
function area_anchor( $uri = '', $title = '', $attributes = '')
{
$title = (string) $title;
if ( ! is_array($uri))
{
$site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
}
else
{
$site_url = site_url($uri);
}
if ($title == '')
{
$title = $site_url;
}
if ($attributes != '')
{
$attributes = _parse_attributes($attributes);
}
return '<area href="'.$site_url.'" title="'.$title.'"'.$attributes.'></area>';
}
} //function
/* End of file area_helper.php */
/* Location: ./application/helpers/area_helper.php */
?>
You can use it like this:
<?php echo area_anchor( "/welcome", "Welcome", 'shape="poly" coords="153,78, 153,78, 154,78, 154,78, 154,78, 154,77, 155,77, 155,77, 155,77, 157,80, 158,81, 158,82, 158,83, 159,83, 160,84, 160,84, 161,84, 160,85, 160,86, 159,86, 159,86, 160,86, 160,86, 160,86, 160,87, 160,87, 159,87, 159,87, 156,86, 155,86, 155,85, 155,85, 155,85, 154,86, 154,86, 154,86, 154,87, 153,87, 153,86, 152,86, 152,86, 151,85, 150,85, 150,85, 150,86, 149,86, 149,86, 149,86, 149,86, 148,86, 148,86, 147,86, 147,86, 148,85, 148,85, 148,85, 148,85, 148,85, 148,84, 148,84, 148,84, 148,84, 149,83, 148,82, 148,82, 148,82, 148,80, 148,80, 149,80, 149,80, 149,80, 149,80, 149,80, 150,80, 150,80, 150,80, 150,80, 150,80, 149,79, 149,79, 149,79, 150,79, 152,79, 152,79, 152,79, 152,79, 153,79, 153,79, 153,78, 153,78, 153,78"'); ?>
If you have any questions don’t hesitate to contact me.
Recent Comments