Custom States in Reusable Element

Dear all,

Can I use custom states in a reusable header to enable language switch in the app?

I am creating a website in two languages. In the header element (reusable) I store a custom state called “language” with value “yes” or “no” with default “yes”. If the user klicks on the text “EN” placed in the header, the value “no” is set. On the other pages I set a condition to check the custom state and show the EN or DE text depending on the state. However, I loose the custom state value when I switch for example from index to product page (even though the value is stored on the reusable element on all pages). Can I make the custom state keep its value while switching pages? Or how could I fix this?

Thanks so much for your help.
Dominic

1 Like
  • Custom states always reset on page refresh / navigation.
  • You also can not store something in a reusable element across pages.

If you need data to persist, you can…
→ save it as cookies or session data in the browser
→ save it as a parameter in the url
→ save it to the database

In your case it probably makes the most sense to either store the setting as a cookie (you would need a plugin for this) or in the database.

2 Likes

@reger-alexander thank you. I used the data base approach and it works! Very much appreciate your time.