I use joomla (a CMS) to build my website, and astroid frameworks (a joomla addon) for template management.
They have the modern restriction of the only user customization being a light/dark switch. I was not happy with this. They'd let me make more templates, but I could only assign them to predetermined pages.
I successfully made a custom module that let the user pick between an unlimited amount of templates, but the selection reset upon going to another page. This is the code for the template picker.
<form id="templateswapform">
<label for="template">Choose a template:</label>
<select name="template" id="template">
<option value="astroid_template_two_pink_blue">Pink and pale blue (light)</option>
<option value="astroid_template_two_purple_green">Purple and green (dark)</option>
<option value="astroid_template_two_orange_pale_green">Orange and pale green (light, animation)</option>
</select><input type="submit" value="Choose">
</form>
You can see it in action here. It's an oldschool expanding options form with a submit button. As you can see, it has 3 options. Pink and pale blue (light); Purple and green (dark); Orange and pale green (light, animation). The values attached to the options are their names on the backend, the options are the text that the form displays when you use it to pick a template.
I spent a few days stuck at this stage, attempting to get joomla to accept a cookie with the chosen template and then display it. I couldn't do that. So I started thinking outside of the box.
The astroid frameworks backend editor lets me make individual changes to each template without affecting the rest of them. This includes which items will be displayed to visitor. Items like menus on the left of my content.
And yesterday when I made my custom error 404 page, I had only inserted the code for it in my default template. My default template is one with a light/dark switch that's not displayed among the options in the code above. Unless told otherwise, that's the one that joomla will show you. After I made the error 404 page, I went to put a link to it in the "just for fun" menu. And I saw that it was asking which template to use when visitors click on the link.
This morning I put those 2 things together for an experiment. I opened the template called astroid_template_two_pink_blue (a template that's the only light version of the default one; astroid_template_two_purple_green is the only dark version of default) and went on to remove the menu and replace it with a template exclusive. On the backend that menu is called "Main menu pink blue", but it shows only "Main menu" to visitors.
When I opened a page in the pink and pale blue template, there was no menu. But joomla lets you link to the same content (that stuff in the middle column on my website; code for it is stored separately from everything you see around it and can be called for insertion) with as many menu items as you want. So I took that template exclusive menu and filled it up with links to the same content, except in the field where it asked which template to load, I selected astroid_template_two_pink_blue. Then I repeated the process for the just for fun menu, and did the same thing for the purple and green template.
I had now successfully made joomla keep the user selected template for menu navigation.¨
And I wasn't done yet. The whole point had been to give more than 2 options. So I made an orange and pale green template in astroid and repeated the process with the menus. And then I added a somewhat modified cursor trail script to that one where I had changed some numbers and accidentally added a delayed confetti trail. I have no idea how, but it's there and I like it. I did this because I can now do animations as an opt in feature.
During the past week, I also asked for help on the joomla forum and was given less than helpful advice like "make a plugin" and instructions on how to make a light/dark switch. Which I already had and my first sentence was that I want more than 2 options.
But thinking outside of the box worked.