Advertisement:

Author Topic: Simple Theme Changer  (Read 41348 times)

Offline GraphicJunki

  • Semi-Newbie
  • *
  • Posts: 31
    • @Graphicjunki on Twitter
    • GraphicJunki
Re: Simple Theme Changer
« Reply #100 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

any help you can give me would be much appreciated

Thanks

Code: [Select]
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>';

Offline danielwmoore

  • Jr. Member
  • **
  • Posts: 110
  • Gender: Male
Re: Simple Theme Changer
« Reply #101 on: November 04, 2011, 12:30:05 PM »
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!

Offline hcfwesker

  • SMF Hero
  • ******
  • Posts: 2,213
  • Gender: Male
  • SMF 2.0.4
Re: Simple Theme Changer
« Reply #102 on: November 09, 2011, 05:17:40 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
Code: [Select]
// 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.

Offline GraphicJunki

  • Semi-Newbie
  • *
  • Posts: 31
    • @Graphicjunki on Twitter
    • GraphicJunki
Re: Simple Theme Changer
« Reply #103 on: November 09, 2011, 07:51:28 PM »
Thanks worked a treat

Offline hcfwesker

  • SMF Hero
  • ******
  • Posts: 2,213
  • Gender: Male
  • SMF 2.0.4
Re: Simple Theme Changer
« Reply #104 on: December 17, 2011, 11:54:55 PM »
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
Code: [Select]
// Show a random news item? (or you could pick one from news_lines...)
Add BEFORE
Code: [Select]
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>';

Offline coolestman

  • Semi-Newbie
  • *
  • Posts: 31
    • Educational Forum
Re: Simple Theme Changer
« Reply #105 on: December 18, 2011, 01:42:18 AM »
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.........

Offline hcfwesker

  • SMF Hero
  • ******
  • Posts: 2,213
  • Gender: Male
  • SMF 2.0.4
Re: Simple Theme Changer
« Reply #106 on: December 18, 2011, 02:39:39 AM »
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.

Offline coolestman

  • Semi-Newbie
  • *
  • Posts: 31
    • Educational Forum
Re: Simple Theme Changer
« Reply #107 on: December 23, 2011, 12:51:26 AM »
i changed the theme manually in the admin.
study to show yourself approve.
study it out.........

Offline hcfwesker

  • SMF Hero
  • ******
  • Posts: 2,213
  • Gender: Male
  • SMF 2.0.4
Re: Simple Theme Changer
« Reply #108 on: December 23, 2011, 02:29:48 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.

Offline felizycontento

  • Semi-Newbie
  • *
  • Posts: 42
Re: Simple Theme Changer
« Reply #109 on: September 14, 2017, 01:51:59 PM »
Is there any current alternative to this mod? I can't make it work in 2.014

Offline br360

  • Lead Support Specialist
  • SMF Hero
  • *
  • Posts: 1,966
    • GenXcommunity
Re: Simple Theme Changer
« Reply #110 on: September 14, 2017, 02:18:42 PM »

Offline felizycontento

  • Semi-Newbie
  • *
  • Posts: 42
Re: Simple Theme Changer
« Reply #111 on: September 14, 2017, 03:44:26 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.