Skip to content

Commit

Permalink
Added "As HTML YouTube link" field_formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
ahtih committed May 22, 2012
1 parent 123c0eb commit 66efd0e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ldiw_waste_map.module
Expand Up @@ -337,6 +337,10 @@ function ldiw_waste_map_theme()
'file' => 'ldiw_waste_map.theme.inc',
),
'ldiw_waste_map_formatter_as_twitter_link' => array(
'arguments' => array('element' => NULL),
'file' => 'ldiw_waste_map.theme.inc',
),
'ldiw_waste_map_formatter_as_youtube_link' => array(
'arguments' => array('element' => NULL),
'file' => 'ldiw_waste_map.theme.inc',
));
Expand Down Expand Up @@ -1236,6 +1240,8 @@ function ldiw_waste_map_field_formatter_info()
'field types' => array('text')),
'as_twitter_link' => array('label' => t('As HTML Twitter link'),
'field types' => array('text')),
'as_youtube_link' => array('label' => t('As HTML YouTube link'),
'field types' => array('text')),
);
}

Expand Down
14 changes: 14 additions & 0 deletions ldiw_waste_map.theme.inc
Expand Up @@ -23,3 +23,17 @@ function theme_ldiw_waste_map_formatter_as_twitter_link($element)

return l($url,$url);
}

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

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

return l($url,$url);
}

0 comments on commit 66efd0e

Please sign in to comment.