Hello. Sorry to bump such an old topic, but I think this is the most appropriate place to get the help I need.
I needed a template switcher for my website, and when I found Sonya's method above I was delighted to see that it worked exactly as I needed it to. I added the hack to my site and used it successfully up until version 1.8.2. In December I upgraded to 1.9.1, and the hack stopped working. I could click on the link I used to change the template and it would reload the page, but the template would not change. This is still not working in 1.9.2.
You can see a dummy site that's still running 1.8.2 and still has the template switcher working
here (links are at the bottom of the left nav in the blue and green layouts, and on the right side of the footer in the default CSS menu top layout). The 1.9.2 site is live, and the links are not present there so that visitors won't be confused by them, but you can test the same thing by visiting
this link and appending "&tpl_id=#" to the URL, where valid template IDs for # are 25, 26 and 27 (if you just want to manipulate the URLs on the dummy 1.8.2 version, valid template IDs are 16, 23 and 24). Nothing happens when you use those URLs on the 1.9.2 site.
Under normal circumstances I would simply use the same template and switch the stylesheet itself, as mentioned by several other users above; it's a method I've used to great effect on plenty of static HTML sites before. And if you look at the site I linked to, you'll also see that two of the layouts are in fact identical save for colors and images. Those two
could use the same template and simply change stylesheets; I currently have them using two separate templates, however, because as you'll see the third option on the dummy site is one of the default CMSMS layouts that uses a completely different template (and, more importantly, a different menu manager template). That's the primary reason for wanting to use different templates: some of my visitors prefer vertical navigation, and others prefer horizontal navigation, and since the horizontal nav with dropdown requires a different menu template, I can't use the same layout template for each design and so am forced to change the templates themselves with the switcher. (Unless there's a way to conditionally change the menu template used in a layout based on the stylesheet chosen? I suppose that would work as well, but am not quite sure how I'd go about that.)
So I guess my question is this: what has changed that would suddenly cause this to stop working between versions 1.8.2 and 1.9.1/1.9.2 (and possibly 1.9; I accidentally missed that upgrade, so I don't know whether it works there or not)? Has the method of handling templates changed or something? Is it simply a matter of adjusting a few terms or variables in the existing hack, or what?
I saw the announcement stating that modifications to core files are heavily discouraged and should not be supported/suggested, and so I'm also wondering if there's a way to use this without modifying index.php. I don't like the idea of modifying index.php either if I don't have to, but since I did have this functionality working for a while it would be a real shame to just up and not have it anymore just because of a quick version upgrade. If fixing the index.php hack itself isn't an option, does anyone know of a way that I could modify it and use it a bit more... safely? Say, as a UDT, or even as a module? I'm starting to learn PHP but haven't yet gone in-depth or taken a serious look at Smarty and how it's used to set up CMSMS specifically (though I will certainly get there!), so as of yet I haven't been able to puzzle out a way to do it myself. :/ Certainly just putting the above code as-is into a UDT and putting the UDT in the templates in question doesn't work, though I suspect that may have been a silly thing to try anyway.
If you need any further information, I'm happy to provide it. Thanks in advance.