Simple Theme Changer

Started by Fustrate, August 19, 2008, 11:29:32 PM

Previous topic - Next topic

GraphicJunki

Hi everyone I know very little about php, If somone could tell me to where abouts in the my Themes index.templates do
I paste the following code please.  I have this mod installed on 2.0.1

any help you can give me would be much appreciated

Thanks


echo '
<select id="simple_theme_changer" onchange="switch_theme();">
<optgroup label="', $txt['simple_theme_changer_name'], '">';

foreach ($context['themes'] as $id => $theme)
echo '
<option value="', $id, '"', (($settings['theme_id'] == $id) ? ' selected="selected"' : ''), '>', $theme, '</option>';

echo '
</optgroup>
</select>

<script language="JavaScript" type="text/javascript">
<!--
function switch_theme(){
theme_changer = document.getElementById("simple_theme_changer");
var id = theme_changer.options[theme_changer.selectedIndex].value;
var page = new String(window.location);

window.location = "index.php?action=theme;sa=pick;type=quick;u=', $context['user']['id'] ,';th=" + id + ";sesc=', $context['session_id'], ';page=" + escape(page);
return false;
}
-->
</script>';

danielwmoore

This is very close to what I am looking for for 2.0.1.

If all I wanted was for current members to be able to change their themes quickly, then I could easily adapt this.  However, I would like it to be smart enough to detect when a user is logged in, and if so, use this as is.  If no user is logged in (a guest is viewing), then I would still like the drop down, but to change the theme for the current session.  This is possible by calling the theme (and variant for themes with a variant) by the theme number.  Such as 'index.php?theme=8;vrt=blue;variant=blue" would set the current session to use theme number 8, with the "blue" variant.  (I have 9 color variants on one theme, 4 on another.) 

I also need to make sure that the selector doesn't just list the themes, but each variant for a theme.

Is anyone willing to take up this mod and do something like this that will be something everyone could actually use?  Then it would be usable by pretty much every SMF 2.0 forum!

hcfwesker

Quote from: saffz on October 17, 2011, 05:50:55 PM
Hi everyone I know very little about php, If somone could tell me to where abouts in the my Themes index.templates do
I paste the following code please.  I have this mod installed on 2.0.1

It's really about where you want it to appear on your forum.  I have it at the bottom of my site, you can see in the link in my sig.  just goto your themes index.template.php file

Find
// Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!

and place the code directly above it.

GraphicJunki


hcfwesker

Just gonna share a more convenient place to put this for members logged in the site.  It'll place the theme selector directly under the search tab.  This is very ideal if you never use the forums' "random news item'

Preview in the attachment below.  If you add it and don't like it, just move it around and see where you rather prefer it to be placed.  This is just a suggestion, and most ideal for custom themes based off the SMF Default Curve theme.

Themes/(your theme)/index.template.php

Find
// Show a random news item? (or you could pick one from news_lines...)

Add BEFORE
echo '
<select id="simple_theme_changer" onchange="switch_theme();">
<optgroup label="', $txt['simple_theme_changer_name'], '">';

foreach ($context['themes'] as $id => $theme)
echo '
<option value="', $id, '"', (($settings['theme_id'] == $id) ? ' selected="selected"' : ''), '>', $theme, '</option>';

echo '
</optgroup>
</select>

<script language="JavaScript" type="text/javascript">
<!--
function switch_theme(){
theme_changer = document.getElementById("simple_theme_changer");
var id = theme_changer.options[theme_changer.selectedIndex].value;
var page = new String(window.location);

window.location = "index.php?action=theme;sa=pick;type=quick;u=', $context['user']['id'] ,';th=" + id + ";sesc=', $context['session_id'], ';page=" + escape(page);
return false;
}
-->
</script>';

coolestman

i changed the theme f my site and some features refused to display lke my ads, blogs and articles
study to show yourself approve.
study it out.........

hcfwesker

Now, did you manually change the theme of your site from your profile, or are you using the Simple Theme Changer MOD?  The way you worded it just makes it seem you saw the title and this was the best place for you to post your problem.

Your issue sounds like you possibly didn't make the manual edits to other themes that those features ask for.

coolestman

i changed the theme manually in the admin.
study to show yourself approve.
study it out.........

hcfwesker

Quote from: coolestman on December 23, 2011, 12:51:26 AM
i changed the theme manually in the admin.

then that has nothing to do with this MOD.  You need to ask for support in those MOD topics.  Most likely you didn't make the edits required to other theme files.

felizycontento

Is there any current alternative to this mod? I can't make it work in 2.014


felizycontento

Quote from: br360 on September 14, 2017, 02:18:42 PM
You can try this one- https://custom.simplemachines.org/mods/index.php?mod=3356

No it doesnt work. This at least shows the switcher, but switching the theme does not have any effect.

Advertisement: