[TIP] Theme changer

Started by Nadrealista, November 13, 2009, 08:24:16 AM

Previous topic - Next topic

Nadrealista

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

Sirius

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..

Arantor

Well, this was marked solved so I can only assume the answer was found.

Nadrealista


shumilica

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.
Today, if you're not confused it means you're not thinking clear!

Eliana Tamerin

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.
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

shumilica

Ok... but I don't know how to do that :(
Can you help? Or anyone else...
Today, if you're not confused it means you're not thinking clear!

Nadrealista

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  ;)

shumilica

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?
Today, if you're not confused it means you're not thinking clear!

Forbs

Where i need to post this code?!

rendy1287

cool, this is that i need... thank you Haяy
http://www.komikita.net [nofollow] - Komunitas Komikus Indonesia - Komik

Sefket

<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?

Eliana Tamerin

Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!


Eliana Tamerin

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>
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

Sefket

Worked, but when I clicked the skin, the theme changer vanished. And how come this makes my forum width change?

Eliana Tamerin

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.
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

Sefket

Ah, alright. How can I put this on the footer?

Eliana Tamerin

Insert it wherever you want in the index.php file.
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

zzuzu

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.

Advertisement: