• Welcome to Simple Machines Community Forum. Please login or sign up.

How to load specific theme for demo?

Started by shadav, September 18, 2021, 04:44:28 PM

Previous topic - Next topic

shadav

I'm asking here since it's about themes
I want to be able to work on multiple themes on my demo site but still be able to display them
for the life of me I can't remember I know there's a url/theme=#
would this work for what I'm trying to achieve? and if so what the heck is the link? I don't want it to override a logged in users settings, but just to use it as a demo link so I can play with different themes without multiple installs

I see a few theme changer mods for 2.0.x but I don't want to install something into the theme that won't be used by the end user (and I forget to remove it)
and only one for smf 2.1.x and I don't particularly care for the looks of it, it's ok but not my cup of tea

another question, how could you make theme variants work like this as well? or is that not possible?

Antechinus

You just use the id of the theme, in the order they were installed. So default is always theme=1, then whatever you install after that.

https://www.simplemachines.org/community/index.php?theme=1
https://www.simplemachines.org/community/index.php?theme=2
Etc, etc...

It's session-dependent (expires if you close the page) and the theme ID appears in your address bar, so you can manually edit it at any time to change themes (if you know what you are doing).

Variants, with a direct url? Not sure. Haven't ever tried it. But, you can easily make a variant switcher. That has been done heaps of times. Can be session-dependent or permanent.

ETA: Oh yeah, obviously you can make your own buttons that have ?theme=35 or whatever as the href. That's the bog-simple way of making a temporary theme switcher.

shadav


Antechinus

Aha! I just had an idea, so went and checked the code for one of my ancient multicolour themes. Variants can be done like this:

        if (empty($context['theme_settings']['disable_user_variant']))           
            echo '
                <ul class="changer">   
                    <li class="changerB"><a href=" ' . $scripturl . '?variant=Bronze"></a></li>
                    <li class="changerD"><a href=" ' . $scripturl . '?variant=Darkside"></a></li>
                    <li class="changerE"><a href=" ' . $scripturl . '?variant=Emerald"></a></li>
                    <li class="changerH"><a href=" ' . $scripturl . '?variant=Hellfire"></a></li>
                    <li class="changerJ"><a href=" ' . $scripturl . '?variant=Jade"></a></li>
                    <li class="changerO"><a href=" ' . $scripturl . '?variant=Opal"></a></li>
                    <li class="changerP"><a href=" ' . $scripturl . '?variant=Pinkbitz"></a></li>                   
                    <li class="changerR"><a href=" ' . $scripturl . '?variant=Ruby"></a></li>
                </ul>';

That's for the theme being the current theme. For theme + variant selection I expect this would be it:

                    <li class="changerR"><a href=" ' . $scripturl . '?theme=35;variant=Ruby"></a></li>
ETA: Just checked the docs. D'oh. :P
Anyway yes, that works. See Changing the Style via URL

shadav


Advertisement: