function yr_verdata_credit_link in Yr Weatherdata 6.2
Same name and namespace in other branches
- 7 yr_verdata.module \yr_verdata_credit_link()
Function for generating a credit link back to yr.no.
Parameters
$url: The url for the location. If not provided, the returned link will be to yr.no's frontpage.
$short: Whether or not the link text should be the full link text or a shorter, for use in blocks.
$text: Used for passing in text in other languages provided by yr.no.
Return value
Returns a link back to yr.no with text that credits yr.no, output by l().
3 calls to yr_verdata_credit_link()
- yr_verdata_block in ./
yr_verdata.module - Implementation of hook_block().
- yr_verdata_page_all in ./
yr_verdata.module - Function for generating the main forecast page.
- yr_verdata_page_single in ./
yr_verdata.module - Function for generating a forecast page for a single location.
File
- ./
yr_verdata.module, line 371 - yr_verdata.module This file contains the code for getting the forecast from yr.no and displaying it on a Drupal site.
Code
function yr_verdata_credit_link($url = FALSE, $short = FALSE, $text = '') {
$link = $url == FALSE ? 'http://www.yr.no' : $url;
if (empty($text)) {
// No link-text was given, use a standard one.
$longtext = t('Weather forecast from yr.no, delivered by the Norwegian Meteorological Institute and the NRK.');
$shorttext = t('Weather forecast from yr.no.');
$text = $short == FALSE ? $longtext : $shorttext;
}
if ($url == FALSE) {
// Standard URL, meaning we can let search engines follow it to give credit to yr.no.
$credit = l($text, $link, array(
'external' => TRUE,
'attributes' => array(
'title' => t('Weather forecast from Yr.no'),
),
));
}
else {
// To prevent too many outgoing links to the same domain, we add rel="nofollow" to some links.
$credit = l($text, $link, array(
'external' => TRUE,
'attributes' => array(
'rel' => 'nofollow',
'title' => t('Weather forecast from Yr.no'),
),
));
}
return $credit;
}