Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=1342)
Simple Theme Changer v1.0
IntroductionSimple Theme Changer allows users to switch themes from any page, without having to go to their profile - all you have to do is pick one from a dropdown list!
Featureso A dropdown box is placed in the bottom right side of most themes' footers. If it doesn't show up in your theme, add the following where you want it to appear (in index.template.php):
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>';
o To use this mod, just pick a theme from the dropdown menu ;)
o There are NO admin features for this modification.
SupportPlease use the modification thread for support with this modification. Personal messages for support are discouraged.
Languageso English
o English UTF-8
If you have any translations for any other languages, I would be grateful if you would send them to me via PM or in the Mods topic.
Changelog> Comment
+ Addition
- Error/bug fix
Version 1.0 Aug. 16th, 2008> Initial Release
(No Version Change) 12th February, 2009> Upgraded for RC1, 1.1.x support added.
Wow, very nice little mod! :D
I have seen this sort of thing around quite a few different theme demo sites. ;)
ya, and there was a mod that was last updated... some time last year? But as far as I could tell there wasn't one for 2.0 :P
if you write a version for 1.1.5 it will be great
[sarcasm]
Hmm, just thinking aloud, anyway of making this use Ajax to change the theme? ;D
[/sarcasm]
Where in the Index.template.php am i supposed to put the code?
It really depends on your theme... sometimes you can go to
</div>';
}
function template_html_below()
and replace it with
<select id="simple_theme_changer" onchange="switch_theme();">
<optgroup label="', $txt['simple_theme_changer_name'], '">';
foreach ($context['themes'] as $theme)
echo '
<option value="', $theme['id'], '"', (($settings['theme_id'] == $theme['id']) ? ' selected="selected"' : ''), '>', $theme['name'], '</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', $context['browser']['is_safari'] ? '.href' : '', ' = 'index.php?action=theme;sa=pick;type=quick;u=', $context['user']['id'] ,';th=' + id + ';sesc=', $context['session_id'], ';page=' + escape(page);
}
-->
</script>
</div>';
}
function template_html_below()
That gave me errors :( is there by chance i can send you the files?
Sure, just attach it here
1. Mystic Jade
2. BacknBlack
3. ClanWar
4. OverView
Please return them in the same order and thank you! :p i love your mods <.<
Argh, I really have to leave...
try placing this right before the ending bracket (}) of template_body_below, right after the </div>';
echo '
<select id="simple_theme_changer" onchange="switch_theme();">
<optgroup label="', $txt['simple_theme_changer_name'], '">';
foreach ($context['themes'] as $theme)
echo '
<option value="', $theme['id'], '"', (($settings['theme_id'] == $theme['id']) ? ' selected="selected"' : ''), '>', $theme['name'], '</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', $context['browser']['is_safari'] ? '.href' : '', ' = \'index.php?action=theme;sa=pick;type=quick;u=', $context['user']['id'] ,';th=\' + id + \';sesc=', $context['session_id'], ';page=\' + escape(page);
}
-->
</script>';
make sure it's AFTER the '; and before the }
and sorry about having to leave... I had no clue I was going to a Dodger game tonight
I still keep getting the same error :( may you attempt it when you return?
I still cant get it right :(
attach your index.template.php to a post
I already did. its one of the posts above.
Oi, you're the one with 4...
Follow the example in this one, it's the first of the 4 themes:
Thank you :P and my site is www.thefinalgathering.co.cc <.< check it out some time XD and ill be putting in the file as soon as i return back home.
what do I have to do, when I don't let a theme in that list?
something like, I want ID: 1, 2, 3, 5, 8
Maybe an array or something?
If you only want certain themes, find this in index.template.php:
foreach ($context['themes'] as $theme)
and add this right after it:
if(in_array($my_themes, $theme['id']))
and right before the foreach(), on the line before it add:
$my_themes = array(1,2, 3, 5, 8);
BTW: could't this theme be compatible with the 1.1.X version of SMF.
I could help if you want.
there is already a mod that does this for 1.1.x... can't remember the exact name though
THERE IS? WHATS IT CALLED? Cause I don't see it lol.
http://custom.simplemachines.org/mods/index.php?mod=746
will you update this please?
thanks
Ya, it's on my list. Long list ;)
Spanish_latin:
$txt['simple_theme_changer_name'] = 'Elegir Tema';
Thanks :) Is that also usable for the other spanish_* language files?
Quote from: YodaOfDarkness on September 30, 2008, 10:31:53 PM
Thanks :) Is that also usable for the other spanish_* language files?
Yes ;)
ah!!!! update this!! lol
Real life takes precedence :-X
I'm probably going to update all of my mods after RC1 comes out, for my own sanity.
.
Extremely welcome mod.
I have a question about :
Quote from: Fustrate on September 09, 2008, 05:53:30 PM
If you only want certain themes, find this in index.template.php:
foreach ($context['themes'] as $theme)
and add this right after it:
if(in_array($my_themes, $theme['id']))
and right before the foreach(), on the line before it add:
$my_themes = array(1,2, 3, 5, 8);
Is there some code I could type there to make the mod automatically check if a theme is enabled ?
See, I haven't tagged all themes in the "
Themes that the user is able to select" page of SMF's Themes and Layout Settings, yet all of them appear in the mod's dropdown menu. Is manually adding/removing themes id the only way to keep the droplist coherent with the enabled themes ?
I'll do that tonight or tomorrow, thanks for pointing that out.
Say, news on that ?
I'll have to manually add the code to many themes (aka: destroy our forum), but I've been waiting for the manual code to be updated.
Please warn me if it won't be, I'll just use it as it is now.
in index.php, find:
// Simple Theme Changer
$request = $smcFunc['db_query']('', '
SELECT *
FROM {db_prefix}themes
WHERE variable = {string:name}
AND id_member = 0',
array('name' => 'name')
);
$context['themes'] = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$context['themes'][$row['id_theme']] = $row['value'];
$smcFunc['db_free_result']($request);
// End Simple Theme Changer
and replace it with
// Make our known themes a little easier to work with.
$enabled_themes = !empty($modSettings['knownThemes']) ? explode(',',$modSettings['knownThemes']) : array();
// Simple Theme Changer
$request = $smcFunc['db_query']('', '
SELECT *
FROM {db_prefix}themes
WHERE variable = {string:name}
AND id_member = 0',
array('name' => 'name')
);
$context['themes'] = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
if(in_array($row['id_theme'], $enabled_themes))
$context['themes'][$row['id_theme']] = $row['value'];
unset($enabled_themes);
$smcFunc['db_free_result']($request);
// End Simple Theme Changer
and see if that works.
Sorry but does this work on 2.0 4 beta?....
I only currently have one skin but...
Yes it should.
Frustrate, great mod! I have two questions in regards to making this compatible with two other mods.
1) Global Headers and Footers Mod (http://custom.simplemachines.org/mods/index.php?mod=351)
What would the HTML code be to make this work with the global headers/footers mod? If this could be used with GHF then it would be automatically on every theme no matter what since GHF works across themes. It seems pretty straight forward, I just can't seem to figure out how to make it work on plain HTML.
2) I tried adding your code to a SimplePortal PHP block and it gave me the drop down OK, but no theme names were listed for some reason. Any idea on how to make that work? Again, this would be a way to make it work across all current and future themes.
Any help is appreciated.
did you do the index.php code too? That's what loads the theme names... and I've never actually tried the GHF mod, so I have no clue what to do.
index.php code? I used the code that you posted to apply wherever I wanted it to appear.
As for GHF it reads plain HTML, so if this can be coded in html... ?
I received an answer on how to add it to SP here: http://simpleportal.net/index.php?topic=1607.msg10652#msg10652
hi, id like this mod to work for guests and not just for members, can the code be changed to allow guests to use the theme changer? if so what edits need to be made please
Good catch, I never even tested it as a gust. Definitely would be helpful.
Quote from: KahneFan on March 17, 2009, 12:05:08 PM
Good catch, I never even tested it as a gust. Definitely would be helpful.
it is if you got themes you want to show off to people as they dont have to log in then
For now I've just put a notice with login info in the block I added to SimplePortal. You can see it on the top left of my home page.
Thank you , very good mod ,
Arabic translation :
<file name="$languagedir/Modifications.arabic-utf8.php" error="skip">
<operation>
<search position="end"></search>
<add><![CDATA[
$txt['simple_theme_changer_name'] = 'تغيير القالب (الإستايل)';
]]></add>
</operation>
</file>
please before put the translation in the file be sure that the file encode is UTF-8
Quote from: stikkki on March 17, 2009, 11:53:43 AM
hi, id like this mod to work for guests and not just for members, can the code be changed to allow guests to use the theme changer? if so what edits need to be made please
any news on this,
mine installd fine but it takes members to their profiles when thry select a new theme.
is that normal or fault?
Try upgrading to this one... I'm pretty sure it'll fix everything (and allow guest to change themes, and only show enabled themes)
Thanks , i tried installing the new one but it stoped loading the themes automatically, i had to switch back to the old one.
how do you set the enabled themes,
i have three themes installed and all of them are showing there
www.afrowall.com
for the new version, you needed to do a hard refresh... ctrl-shift-r or cmd-shift-r because the javascript that switches it is now in an external script file.
ive tried installing the new version on 2.0 rc1 and the themes dont change - ive done the hard refresh and had no errors on install
go to /Themes/default/scripts/script.js and check if there is a theme function at the end of it.
I have the same thing, the drop down box is there but no matter which theme I choose it doesn't change.
I have checked the script.js file and the theme function is there at the end of it.
I'm using 1.1.8 and default theme.
Have you done a hard refresh (shift-ctrl-r or shift-cmd-r)? If that doesn't work, can you PM me a link to your forum so I can test it out?
Quote from: jellie on April 30, 2009, 04:10:00 AM
I have the same thing, the drop down box is there but no matter which theme I choose it doesn't change.
I have checked the script.js file and the theme function is there at the end of it.
I'm using 1.1.8 and default theme.
I tried this mod about two weeks ago on a new install and ran into the same issue with v1.1.8. I didn't have Pretty URLs installed yet, so that couldn't have been the issue. I didn't know about the hard refresh, so don't know if that would have cured it. I ended up using the older SMF Quick Theme Changer, and rewrote parts of it to get it to work properly and how I wanted (alpha sort, and with a reset to board defaults option, and working with Pretty URLs too). See page 4 of that mod's thread.
Oh the redirect to the user profile affected that mod too, which was solved.
Fustrate, take a look at how that mod works, might help you track down any issues with yours.
All i get is a drop down with
Array
Array
Array
Array
no themes to select????
any help would be fantastic..
does it work 2.0rc1-1
Quote from: neteater on July 03, 2009, 05:15:35 AM
does it work 2.0rc1-1
No. I Just tried installing the package, it's not compatible with SMF 2.0 RC1-1 .
is there any ways to make this mod to work on RC2-1 without having to edit some php codes? that would be nice.
on the bottom right of the page that lists your uploaded packages, look for a box that says something about Emulate Version, and change it to plain 2.0
That does work, kind of. The changer drop down appears in the bottom right of the standard theme, but clicking on a different theme doesn't refresh the page, and there's no select button either?
This seems to be the only mod of this kind for SMF 2. Some support for using it in RC1.2 would be highly appreciated!
i have installed tis packageand when you try to use them themes installed listed in Simple Theme Changer 1.0.1 and i click on a theme, thenthey jst dont work.
is there sme kinda edit i need to do, if so what is it i need to edit to getthis to work, or is there a theme changing program that does work on 1.1.10 SMF
Cheers
do i add this code in the main index file located in themes, if so i tried it and it didn`t work ?
I'm working on a better version, javascript is kicking my butt though :P
ok Fustrate, cheers for that,....i will wait for a much better version written by you.
Cheers
expect it in about 7 hours when I get back from work.
Now? lol ;)
6.5 hours :( I'm at work, and don't have access to one of the things I need
its ok,...dont rush,...when your ready really :)
Cheers
Sorry bout the lateness, I can't say why it's late though =\ I had other things that had to be dealt with.
Try upgrading with this package
have you tested it on 1.1.10 as it dont seem to work on mine.
cheers
I found an error on smf 1.1.8:
Not Acceptable
An appropriate representation of the requested resource /forum/index.php could not be found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I use simpleportal and ive tried the code given in simpleportal but still got the same error. My forum is http://bincangprofesi.com/forum/index.php?action=forum
Nvm, the javascript cause trouble too that i couldnt add bb code and smiley in post. This should be great mod though :)
Hi, nice mod. I've got it working okay on 2.0RC2 (I moved it to the top of the Curve theme just under the news). But is there a method or option I can added that changes the person's selected theme to their permanently selected theme. Just like that had selected it via their profile?
It's okay for guest to have it current session based, but I'd like it to be permanent for logged in users. To override the boards default board in other words.
Was just wondering if you were aware that, at least in 1.1.10, the package double installs the mod so you have two drop downs, one on top of the other. It is easily resolved by simply removing the second drop down it installs in the index.template however.
This is the bit it adds twice.
<tr>
<td colspan="3" style="text-align: right;">
<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>
</td>
</tr>
Quote from: Rumbaar on November 18, 2009, 06:52:56 PM
Hi, nice mod. I've got it working okay on 2.0RC2 (I moved it to the top of the Curve theme just under the news).
:'( I wish i would be able to do that on my RC2 .. I'll try again but I am afraid to edit the codes on my main forum.. I'm really not good at this . This mod should be a feature of SMF2...... 80% of the members don't change their themes because they have a hard time to find out how to do it.. ( mostly old timers over 50 years old )
so if I simply upload and try to install the package , it won't work key ?
Any news on that ? Is it officially compatible with 2.0RC2, or is anyone working for a practical theme changer for 2.0RC2 ?
up, for rc2 ?
Hello.. great mod, and thanks for it : ]
I have a question.. how do i put text like adding "Choose Another Theme" above the dropdown box ?
thx in advance : ]
Okay I installed it for RC 2.0 and I get this error when I try to change themes:
QuoteForbidden
You don't have permission to access /tnc/index.php on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Anyone know what the deal is?
up for rc3?
Can we do the same with this.
But instead of changing the theme, changing the style.css (multicolored theme)
anything like this for rc2/rc3/rc4?
can someone update this for RC4 ?
Uhm Im trying to parse the mod on the ... well page the mod is on, but when I select 2.0 RC1, 2.0 RC1.2 it says it's not compatible with those two but it's listed that it is... anyone know what's up with that?
I think it should work with any 2.0 RCx version. You just need to modify the package-info.xml in the package a bit and repackage it. Just modify the part of the available one to this:
<install for="2.*">
<readme type="file" parsebbc="true">readme.txt</readme>
<modification>install_2-0.xml</modification>
<modification>languages.xml</modification>
</install>
<uninstall for="2.*">
<readme type="inline">I'm sorry that things didn't work out between us... we can still be friends though!</readme>
<modification reverse="true">install_2-0.xml</modification>
<modification reverse="true">languages.xml</modification>
</uninstall>
<upgrade from="1.0" for="2.*">
<readme type="file" parsebbc="true">readme.txt</readme>
<modification>upgrade_2-0.xml</modification>
</upgrade>
<upgrade from="1.0.1" for="2.*">
<readme type="file" parsebbc="true">readme.txt</readme>
<modification>upgrade_2-0_v-1-0-2.xml</modification>
</upgrade>
^^ installed perfectly with 2.0 RC4! Everyone just needs to be sure to add the extra bit in the first post.
Just wish it kept you on the same page when selecting themes, but it's better than nothing :)
Does this work for 2.0?
Sure does. Read my post above yours. Even if you have to emulate to RC4, it works, got it on my 2.0 forum
dead support, but was kinda hoping if anyone would know how to change the location of the drop down. I'd prefer it right below the search box
smf 2.0
http://www.brawldomain.com
Just modify the edits it makes to the template(s).
I think i tried that before, but couldn't get it to align to the right side
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>';
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!
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.
Thanks worked a treat
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>';
i changed the theme f my site and some features refused to display lke my ads, blogs and articles
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.
i changed the theme manually in the admin.
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.
Is there any current alternative to this mod? I can't make it work in 2.014
You can try this one- https://custom.simplemachines.org/mods/index.php?mod=3356
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.