Dynamic Content Based on Form Selection & Weather API


(Tbaatar) #1

Hi,

 

I'm trying to get my head around displaying dynamic content based on the visitors location and an API call the Weather service to display the relevant information from a predefined list/tagged of content.

 

This is what should happen.

 

1. User selects their current location from a form e.g London, UK, and the value is saved to the Session

2. Based on this location value the current Weather data is requested through an API

3. The result from the Weather API is looked up & compared to the list of predefined content

4. Finally, the session should display only the relevant content that matches the Weather information of the user.

 

So if the user selected London, UK and if the weather is nice and warm it should retrieve and display "Pimms o'clock!" page. Or if the weather was rainy and cold it should display "Have a mash + pie" with 20% discount.

 

 

Any pointers or help very much appreciated.

 

Thanks.


(Bart Banda) #2

If you are doing it all via JS, you can simply just write a JS function that checks the 2 values, one for the location and one for the weather info. Based on that, the JS can then show/hide the relative content div with changing class names. 

 

If you are wanting to do it all via the backend, you could either try using the conditional keywords functionality on paint layouts, or just use global keywords with modifiers. For example:

 

%globals_session_<variable>^eq:London:TRUE% 

 

Does that help?


(Tbaatar) #3

I want to try the back end solution first.

 

I suspected the Paint Layout approach would be the most likely option.

 

Thanks for the pointer.