Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Nadrealista on November 13, 2009, 08:24:16 AM

Title: [TIP] Theme changer
Post by: Nadrealista on November 13, 2009, 08:24:16 AM
Index.template.php
echo '
      <div style="float:left; position:absolute; left:400px; z-index: 1;">
   <select onchange="location=this.options[this.selectedIndex].value">

<option value="', $scripturl, '"><------ Choose theme ------></option>

         <option value="', $scripturl, '?theme=THEMEID">Theme name</option>
         <option value="', $scripturl, '?theme=THEMEID">Theme name</option>';

echo '
   </optgroup>
</select>


This theme changer is very simple. And members and guests can change themes. Enjoy.  ;)

Demo: http://demo.belstudio.biz.hr/index.php
Title: Re: Theme changer
Post by: Sirius on November 22, 2009, 07:12:38 PM
I wish we had a follow up on this...   the members seem to have a hard time, or too lazy , to find out where to manage their themes..
Title: Re: Theme changer
Post by: Arantor on November 22, 2009, 07:44:52 PM
Well, this was marked solved so I can only assume the answer was found.
Title: Re: [TRICK] Theme changer
Post by: Nadrealista on December 02, 2009, 01:55:36 PM
First post edited, enjoy.  ;)
Title: Re: [TIP] Theme changer
Post by: shumilica on December 07, 2009, 07:59:13 AM
Thank you Hary for this tip, but I want the link to change the users theme permanently. With your option it only changes for the session he is in.
I tried with this:

<a href="http://www.domain.com/forum/index.php?action=profile;area=theme;sa=pick;u=', $context['id_member'], ';th=2;sesc=', $context['session_id'], '">

but it redirects the user to the Look and Layout page from the profile, without changing the theme.

I want at least to change the theam, even tough it will redirect to the profile page.

Any change on doing this from any page of the forum? Because if i'm in the profile page the change works.
Title: Re: [TIP] Theme changer
Post by: Eliana Tamerin on December 07, 2009, 08:17:00 AM
Suggestion: Less hardcoded links:

echo '
      <div style="float:left; position:absolute; left:400px; z-index: 1;">
   <select onchange="location=this.options[this.selectedIndex].value">

<option value="', $scripturl, '"><------ Choose theme ------></option>

         <option value="', $scripturl, '?theme=THEMEID">Theme name</option>
         <option value="', $scripturl, '?theme=THEMEID">Theme name</option>';

echo '
   </optgroup>
</select>


@shumilica: I think you have to do that by $_POST, that's how I've seen portals code it.
Title: Re: [TIP] Theme changer
Post by: shumilica on December 07, 2009, 11:46:51 AM
Ok... but I don't know how to do that :(
Can you help? Or anyone else...
Title: Re: [TIP] Theme changer
Post by: Nadrealista on December 07, 2009, 02:37:09 PM
Quote from: shumilica on December 07, 2009, 07:59:13 AM
Thank you Hary for this tip, but I want the link to change the users theme permanently. With your option it only changes for the session he is in.
I tried with this:

<a href="http://www.domain.com/forum/index.php?action=profile;area=theme;sa=pick;u=', $context['id_member'], ';th=2;sesc=', $context['session_id'], '">

but it redirects the user to the Look and Layout page from the profile, without changing the theme.

I want at least to change the theam, even tough it will redirect to the profile page.

Any change on doing this from any page of the forum? Because if i'm in the profile page the change works.

This is just for previews (my code), for design sites etc. There is a mod who can help you.
Here is a link: http://custom.simplemachines.org/mods/index.php?mod=1342
But that mod have some problems with IDs or something similar. Just first letter of theme is showing.

Quote from: Eliana Tamerin on December 07, 2009, 08:17:00 AM
Suggestion: Less hardcoded links:

echo '
      <div style="float:left; position:absolute; left:400px; z-index: 1;">
   <select onchange="location=this.options[this.selectedIndex].value">

<option value="', $scripturl, '"><------ Choose theme ------></option>

         <option value="', $scripturl, '?theme=THEMEID">Theme name</option>
         <option value="', $scripturl, '?theme=THEMEID">Theme name</option>';

echo '
   </optgroup>
</select>


@shumilica: I think you have to do that by $_POST, that's how I've seen portals code it.

I completely forgot that. Code updated  ;)
Title: Re: [TIP] Theme changer
Post by: shumilica on December 07, 2009, 04:15:11 PM
Thanks, but it's not what I want. I want to change the theme from colored icons in the upper corner. I can't seem to translate the logic in the mod to put it for images and not a dropdown menu. Somebody does?
Title: Re: [TIP] Theme changer
Post by: Forbs on October 04, 2010, 09:14:38 AM
Where i need to post this code?!
Title: Re: [TIP] Theme changer
Post by: rendy1287 on October 05, 2010, 05:18:52 AM
cool, this is that i need... thank you Haяy
Title: Re: [TIP] Theme changer
Post by: Sefket on October 21, 2010, 11:28:10 AM
<div style="float:left; position:absolute; left:200px; z-index:

1;">
   <select onchange="location=this.options[this.selectedIndex].value">

<option value="', $scripturl, '"><------ Choose theme ------></option>

         <option value="', $scripturl, '?theme=Babylon

Theme">Baby</option>
         <option value="', $scripturl, '?theme=THEMEID">Theme

name</option>';

echo '
   </optgroup>
</select>


I added Babylon theme, but it shows this when I click it:

The requested URL /forum34/', $scripturl, ' was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Why is that?

And it stretches my forums, how can I make it the normal forum size?
Title: Re: [TIP] Theme changer
Post by: Eliana Tamerin on October 21, 2010, 12:14:19 PM
Link to your forum?
Title: Re: [TIP] Theme changer
Post by: Sefket on October 21, 2010, 01:08:56 PM
http://www.pure-nation.com/forum34/
Title: Re: [TIP] Theme changer
Post by: Eliana Tamerin on October 21, 2010, 01:39:31 PM
No idea why it's throwing out the scripturl errors, but you can get around it by hardcoding the links.

Also, why are you writing in the theme name? You need the theme ID. That is, if you navigated to http://www.pure-nation.com/forum34/index.php?theme=3, that would be Babylon and the theme ID is 3.

Try something like this:
echo '
      <div style="float:left; position:absolute; left:200px; z-index: 1;">
   <select onchange="location=this.options[this.selectedIndex].value">

<option value="', $scripturl, '"><------ Choose theme ------></option>

         <option value="http://www.pure-nation.com/forum34/index.php?theme=1">Default Theme</option>
         <option value="http://www.pure-nation.com/forum34/index.php?theme=2">Classic Theme</option>
         <option value="http://www.pure-nation.com/forum34/index.php?theme=3">Babylon Theme</option>';

echo '
   </optgroup>
</select>
Title: Re: [TIP] Theme changer
Post by: Sefket on October 21, 2010, 01:56:08 PM
Worked, but when I clicked the skin, the theme changer vanished. And how come this makes my forum width change?
Title: Re: [TIP] Theme changer
Post by: Eliana Tamerin on October 21, 2010, 02:25:12 PM
Theme changer vanished because it's not applied to each skin. You have to modify the index.php of every theme to get it to show up on there.

As for the forum width, it's probably because the div wasn't closed properly in the code. Try this one:
echo '
      <div style="float:left; position:absolute; left:200px; z-index: 1;">
   <select onchange="location=this.options[this.selectedIndex].value">

<option value="', $scripturl, '"><------ Choose theme ------></option>

         <option value="http://www.pure-nation.com/forum34/index.php?theme=1">Default Theme</option>
         <option value="http://www.pure-nation.com/forum34/index.php?theme=2">Classic Theme</option>
         <option value="http://www.pure-nation.com/forum34/index.php?theme=3">Babylon Theme</option>';

echo '
   </optgroup>
</select>
</div>


That should reset the forum width.
Title: Re: [TIP] Theme changer
Post by: Sefket on October 21, 2010, 02:30:04 PM
Ah, alright. How can I put this on the footer?
Title: Re: [TIP] Theme changer
Post by: Eliana Tamerin on October 21, 2010, 11:53:13 PM
Insert it wherever you want in the index.php file.
Title: Re: [TIP] Theme changer
Post by: zzuzu on October 30, 2010, 03:25:04 AM
I tried to insert into multiple places in that index file but it keeps showing up parse error (or something). Can you give me example where to insert it exactly? I would love to have it in footer. Thanks in advance.