Ad

Typo3, How To Dynamically Change Content

- 1 answer

Problem

There is the requirement, to swap out the logo, based on a choice, the user makes on first visit. (Logo for internationals and logo for north America)

What I came up with

On fist thought this problem can be solved using a cookie. I implemented some javascript, to check and set the cookie if needed. This works fine so far but using javascript to change to logo isn´t the way to go and now I´m looking for possible solutions to this.

Some thoughts

If following the cookie approach, I´d need a way to swap out the template/partials, based on the cookie. Is there any way to do this using fluid or typoscript perhaps?
Maybe the cookie approach is the wrong way to handle this at all? Maybe this could be done (ab-)using the language selection or something like that?

Any help or ideas are appreciated.
Thanks!

Ad

Answer

First of all: Please use a question title that describes the problem more precise.

After setting the cookie with your javascript, you can set the logo to render in the TypoScript.

With a condition (https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Conditions/Index.html#request-getcookieparams) you can read the cookie parameter and set the logo depending on the cookie.

[request.getCookieParams()['logo'] == 'us']
lib.logoFile = pathToYourLogos/us.svg
[else]
lib.logoFile = pathToYourLogos/international.svg
[end]
Ad
source: stackoverflow.com
Ad