Change Location of Weather on Calendar

Is it possible to change the location of the weather on the calendar? We don’t currently show it at all on our calendar, but are interested in doing so if we are able to customize where/when it displays.

I see the following code in the lw_cal_day.html component…

{[ if ( { ]}
    <div id="lw_cal_weather">
        Weather in {{ weather.location }}:<br />
        <span>{{ weather.description }}</span>
{[ } ]}

But I can’t see any way to move that elsewhere on the page. I was hoping to place it right below the mini-cal in the right sidebar on our Events Calendar · Angelo State University. But moving that code into lw_cal_mini_cal.html does not work, and it breaks the mini-cal in the process.

Also, in my testing, it seems like the weather only loads when you are on “Today” on the calendar. Is it possible to get it to load for other views too?

Hi Jon,

Good catch! It does look like currently those {{ weather }} variables are limited to the calendar day view. As an alternative, there is a $_LW->getWeather function $_LW Functions - LiveWhale Support that could be used in a custom module to get those values into any other XPHP variables. Anything that you populate into $GLOBALS['foobar'] will be available as <xphp var="foobar"/> on the front-end.

Here’s the core snippet from the calendar, if you wanted to try reproducing it in a module, which shows how the description and location variables get split.

	if (!empty($weather['description']) && !empty($weather['location'])) { // format weather data
		if (strpos($weather['location'], ',')!==false) {
			$weather['location']=substr($weather['location'], 0, strpos($weather['location'], ','));
		$weather['description']=preg_replace('~([0-9]+.\s+)~', '\\1and ', strtolower($weather['description']));

If you decide to go this route, I generally suggest using the onBeforeOutput handler when defining XPHP variables, since it runs “late” in the process but before widgets and XPHP are rendered. Hope this helps!

1 Like