Skip to content

Commit

Permalink
Added "As HTML Twitter link" formatter for Text fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ahtih committed Aug 4, 2011
1 parent 162b60f commit ae024f0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
9 changes: 8 additions & 1 deletion ldiw_waste_map.module
Expand Up @@ -333,6 +333,10 @@ function ldiw_waste_map_theme()
'file' => 'ldiw_waste_map.admin.inc',
),
'ldiw_waste_map_formatter_as_link' => array(
'arguments' => array('element' => NULL),
'file' => 'ldiw_waste_map.theme.inc',
),
'ldiw_waste_map_formatter_as_twitter_link' => array(
'arguments' => array('element' => NULL),
'file' => 'ldiw_waste_map.theme.inc',
));
Expand Down Expand Up @@ -1229,5 +1233,8 @@ function ldiw_waste_map_country_status($country_code)
function ldiw_waste_map_field_formatter_info()
{
return array('as_link' => array('label' => t('As HTML link'),
'field types' => array('text')));
'field types' => array('text')),
'as_twitter_link' => array('label' => t('As HTML Twitter link'),
'field types' => array('text')),
);
}
17 changes: 16 additions & 1 deletion ldiw_waste_map.theme.inc
Expand Up @@ -6,5 +6,20 @@ function theme_ldiw_waste_map_formatter_as_link($element)
if (empty($element['#item']['value'])) {
return '';
}
return l($element['#item']['value'],$element['#item']['value']);
$url=$element['#item']['value'];
return l($url,$url);
}

function theme_ldiw_waste_map_formatter_as_twitter_link($element)
{
if (empty($element['#item']['value'])) {
return '';
}
$url=$element['#item']['value'];

if (strpos($url,'/') == FALSE) {
$url='http://twitter.com/' . $url;
}

return l($url,$url);
}

0 comments on commit ae024f0

Please sign in to comment.