function theme_yr_verdata_forecast in Yr Weatherdata 6.2
Same name and namespace in other branches
- 7 yr_verdata.module \theme_yr_verdata_forecast()
Theme function for displaying the forecast for a location on that location's main forecast page. Caching is done for the whole page, so we don't need to do it here.
Parameters
$vars: An array with the processed forecast information for this location, each element in the array should be one tabular period from the xml.
Return value
Returns themed output with forecast in boxes for this location.
File
- ./
yr_verdata.module, line 915 - yr_verdata.module This file contains the code for getting the forecast from yr.no and displaying it on a Drupal site.
Code
function theme_yr_verdata_forecast($vars) {
$output = '<div id="yr-longterm-forecast" class="yr-forecast-boxes clear-block">';
if ($vars[4]['period'] != '0') {
// The first day should have a heading that says "Tomorrow".
$output .= '<h4>' . t('Tomorrow') . '</h4>';
$period_class = 'yr-period-margin-' . $vars[4]['period'];
$output .= '<div class="yr-longterm-day ' . $period_class . ' clear-block">';
}
foreach ($vars as $item) {
// Create a "new line" for each day of the forecast. Also, add a header saying which day this is.
if ($item['period'] == '0' || isset($item['following'])) {
$output .= '<h4>' . ucfirst($item['day']) . '</h4>';
// ucfirst() because these are headers.
$output .= '<div class="yr-longterm-day clear-block">';
}
$output .= yr_verdata_forecastbox($item);
// Close the "day-line".
if ($item['period'] == '3' || isset($item['last'])) {
$output .= '</div><!-- /.yr-longterm-day -->';
}
}
$output .= '</div><!-- /#yr-longterm-forecast -->';
return $output;
}