Connecting to the Weather Module in Drupal 7

I have a web site that has block of data for a device. The device is at an address and I would like to show the weather at this address on the web site. Enter the Weather module.

My Hack is simple. In this case, I am trying to change as little as possible – and definitely not modify the core module.

We need three variables – are all stdClass.

$display = weather_get_display_settings('default', 1);
$location = new stdClass;
$metar = weather_get_metar("YMML");

Also, I don’t want the “Report On” line, so remove it.


The theming is done by

$content = theme('weather_theming', array('display' => $display, 'location' => $location, 'metar' => $metar));

To change the layout slightly, lets dynamically add a stylesheet

$csspath = drupal_get_path('module', 'wemeter') . "/css/weather.css";
$stylesheets = drupal_add_css($csspath);

which has this content.

.weather img {
    float: right;
    padding-right: 10px;

Leave a Reply