Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Weather Forecast Block

No security coverage Maintenance fixes only 7 sites

This module adds a block that displays weather forecasts based on a configured region. It requires the Geolocation Field module.

Weather Forecast provides a block that shows the current weather, and optionally a forecast for the coming days, for any place in the world. Data comes from OpenWeatherMap, and the free plan is all you need.

Place the block, type a city name, and you're done. Small towns work too, because place names are looked up with OpenWeatherMap's geocoding service before the weather is fetched.

Features

  • Current weather: temperature, conditions and icon, with optional details: feels-like temperature, wind, humidity, sunrise and sunset.
  • Forecast for the next 1 to 5 days, with daily highs and lows and an icon for each day.
  • Any location:
    • a city or town name, optionally with a country code to tell places with the same name apart, for example Springfield,US;
    • or exact latitude and longitude.

    Saving the block checks that OpenWeatherMap knows the place, and confirms which one was found.

  • Metric or imperial units (°C and m/s, or °F and mph), per block. Place several blocks to show several cities.
  • Local time: the observation time, sunrise and sunset are shown in the city's own time zone, not your site's.
  • Multilingual: weather descriptions follow the visitor's language, and all labels are translatable.
  • Fast and within free-plan limits: weather data is cached, 15 minutes by default, so the API is called at most once per location in that time, not on every page view.
  • Safe with your API key: the key is checked when you save it and never written to the logs. You can keep it out of configuration exports by setting it in settings.php.
  • Themeable: the output uses the weather-forecast.html.twig template and a small stylesheet.

Requirements

  • Drupal 10.3 or later, or Drupal 11.
  • A free OpenWeatherMap API key. The module uses the Current weather, 5 day / 3 hour forecast and Geocoding APIs, which are all included in the free plan. New keys can take a couple of hours to become active.

No other modules are needed. Since 1.0.6, Weather Forecast no longer depends on the Geolocation module, so it can be installed alongside any version of Geolocation, or without it.

Installation

Install as you would normally install a contributed Drupal module. For further information, see Installing Drupal Modules.

composer require drupal/weather_forecast
drush pm:enable weather_forecast

Configuration

  1. Go to Configuration » Web services » Weather API settings (/admin/config/services/weather-settings) and enter your API key. Optionally, change how often the weather is updated.
  2. Place the Weather forecast block at Structure » Block layout, and choose the location, units, number of forecast days and whether to show the details.

To keep the API key out of configuration exports, set it in settings.php instead:

$config['weather_forecast.weather_settings']['api_key'] = getenv('OPENWEATHERMAP_KEY');

Support

Report bugs and request features in the issue queue.

Drupal 10–11

Ask your assistant about Weather Forecast Block

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • block Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
7
Tracked since
Sep 2024
Latest release
1 month ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
1.0.6 Stable 10–11 Oct 15, 2026
1.0.5 Stable 10–11 May 12, 2026
1.0.4 Stable 10–11 Sep 28, 2024
1.0.3 Stable 10–11 Sep 25, 2024
1.0.2 Stable 10–11 PHP >=8.1 Sep 25, 2024
1.0.1 Stable 10–11 PHP >=8.1 Sep 25, 2024
1.0.0 Stable 10–11 PHP >=8.1 Sep 24, 2024