Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=746)
Keywords: Theme, quick, changer, select
Description:Adds a drop down theme selector to the footer of all pages
Version 1.0.0:
- Adds a drop down theme changer to footer.
- Works with default theme and any theme without its own index.template.php file.
- Keeps you on the same page when theme is changed.
Install:
- Download the SMF_Quick_Theme_Changer_1.0.0
- Import from the package manager.
To install on themes with their own index.template.php file you'll need to make the edits to that file manually. Open the QuickThemeChanger.xml file, look for the changes being made to index.template.php, and hand edit the themes index.template.php file to apply the edits.
Wow thank you so much for this mod its great. I have been waiting for this mod!
==edit===
Is there a way to make it sure on every theme?
thank you so much! Just what I was looking for today.
nada
thanks
can someone explain how the code keeps the user on the same page after changing the theme? for me, it only seemed to work on the admin user, but on regular users, it sends you to the forum.
thanks,
nada
EEK! I ended up with four changers and some well-screwed code!
To quatify that, The changer appeared. When I clicked on a theme, the page refreshed but the theme hadn't changed.
I selected, again.
The theme changed, but there were, now, two changers.
If I clicked the top one, the theme changed. If I clicked the bottom one, the theme stayed the same, but three changers appeared.
If I clicked the top one, the theme changed. If I clicked any of the others, the theme stayed as it was and there appeared yet another changer!
Very nice mod!
What part of the code i have to paste into template.index.php file in my other themes? I looked on .xml file but everything there seemed to me logical to be copied, lol!
:)
This mod was working great for me, but I wanted guests to be allowed to change themes. I really liked the feature where the user was sent back to where he was. So, I had to sacrifice the option to _SAVE_ the new theme selection in the user's profile. I will tell my members to go into their profile and make the change permanent.
I had to make all my edits manually because I run Ultiportal on my setup.
one change I made was that instead of:
loc = \'index.php?action=theme;sa=pick;saa=quick;u=', $context['user']['id'] ,';th=\' + id + \';sesc=', $context['session_id'], ';url=\' + escape(url);
i used this:
loc = \'index.php?theme=\' + id + \';saa=quick\' + \';url=\' + escape(url);
I made no changes to themes.php
in load.php in the sources folder
look for:
// The theme was specified by REQUEST.
elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
{
$ID_THEME = (int) $_REQUEST['theme'];
$_SESSION['ID_THEME'] = $ID_THEME;
and after that put:
if (isset($_REQUEST['saa']) && $_REQUEST['saa'] == 'quick')
redirectexit($_REQUEST['url']);
and, for Ultiportal systems, just add his changes for the homepage's index.php in the same place you did for the index.php for the forum.
you can see how they work on my bbs at http://heartdaughter.com/
again, the change is NOT saved in the user profile.
thanks for this great mod,
nada
Great mod. But for users to send back to where they were and to allow guests to select theme...
First please install the original mod.
Then...
Open Themes.php
Find:
redirectexit('action=profile;sa=theme');
Replace with:
if (isset($_REQUEST['saa']) && $_REQUEST['saa'] == 'quick')
{
redirectexit($_REQUEST['url']);
}
else
{
redirectexit('action=profile;sa=theme');
}
Now we have to edit quick_theme_changer function.
So open index.template.php
Find:
var url = new String(window.location);
loc = \'index.php?action=theme;sa=pick;saa=quick;u=', $context['user']['id'] ,';th=\' + id + \';sesc=', $context['session_id'], ';url=\' + escape(url);
window.location = loc;
Replace with:
var url = new String(window.location);';
if (!$context['user']['is_guest'])
{
echo '
loc = \'index.php?action=theme;sa=pick;saa=quick;u=', $context['user']['id'] ,';th=\' + id + \';sesc=', $context['session_id'], ';url=\' + escape(url);
window.location = loc;';
}
else
{
echo '
loc = \'index.php?theme=\' + id;
window.location = loc;';
}
echo '
Now all the users will send back to where they were...
And guests can select theme...
THANK YOU THANK YOU THANK YOU!!!
YAY!
nada
Any ideas as to what might be screwing mine?
Quote from: kat on April 09, 2007, 11:16:07 AM
Any ideas as to what might be screwing mine?
Not exactly sure
When I look at ... bugger. Indextemplate, I think it was, the section of code for this mod seems to have replicated.
Most odd.
Quote from: kat on April 09, 2007, 05:26:01 PM
When I look at ... bugger. Indextemplate, I think it was, the section of code for this mod seems to have replicated.
Most odd.
Is it working now? I was going to ask if you got any errors in the installtion
Quote from: ladynada on April 09, 2007, 11:10:23 AM
THANK YOU THANK YOU THANK YOU!!!
YAY!
nada
You are welcome ;)
Quote from: shadow82x on April 09, 2007, 06:46:50 PM
Quote from: kat on April 09, 2007, 05:26:01 PM
When I look at ... bugger. Indextemplate, I think it was, the section of code for this mod seems to have replicated.
Most odd.
Is it working now? I was going to ask if you got any errors in the installtion
No, it's not. :(
As I say, the code keeps replicating, somehow.
Weird.
There were no errors reported, on installation.
Quote from: kat on April 10, 2007, 06:00:34 AM
Quote from: shadow82x on April 09, 2007, 06:46:50 PM
Quote from: kat on April 09, 2007, 05:26:01 PM
When I look at ... bugger. Indextemplate, I think it was, the section of code for this mod seems to have replicated.
Most odd.
Im not sure what to say
Is it working now? I was going to ask if you got any errors in the installtion
No, it's not. :(
As I say, the code keeps replicating, somehow.
Weird.
There were no errors reported, on installation.
Nice mod :)
I want to manually apply this mod to all my other themes, but sadly, I can`t figure out what and where to edit . Could someone please point out to me what lines of code in the .xlm file I will have to paste into the index.template.php-files? And also give some clues to where in index.template they should be placed. Thanks...
Quote from: Iron IC on April 10, 2007, 05:44:04 PM
Nice mod :)
I want to manually apply this mod to all my other themes, but sadly, I can`t figure out what and where to edit . Could someone please point out to me what lines of code in the .xlm file I will have to paste into the index.template.php-files? And also give some clues to where in index.template they should be placed. Thanks...
Same here...not sure what to do.
<search position="before"><![CDATA[<table cellspacing="0" cellpadding="3" border="0" align="center" width="100%">]]></search>
<add><![CDATA[
<!-- // Quick Theme Changer Start -->
<tr>
<td colspan="3" style="text-align: left;">
<select name="quick_theme_changer" onchange="quick_theme_changer(this)">
<optgroup label="', $txt['quick_theme_changer'], '">';
foreach ($context['themes'] as $theme)
{
echo '<option value="', $theme['id'], '"', (($settings['theme_id'] == $theme['id']) ? ' selected' : ''), '>', $theme['name'], '</option>';
}
echo '</optgroup>
</select>
</td>
</tr>
<!-- // Quick Theme Changer End -->
Is the code that needs to be added ... I found the line where it replaces, but does the <![CDATA[ get replaced?
Nice little mod. :D
Great mod thanks alot!
just to let people know, that I needed to make a change in the code to get validation.
I had to use
? 'selected="selected"' :
I am using a modified version of this theme changer
thanks
nada
This seems like a great mod, but it just doesnt make sense.
I installed it correctly on the default theme, and nothing happened.
It would also be nice if you could tell us exactly what code needs to be replaced in order for it to work in other themes in the index.template.php file.
heyas , I got this installed , I also did the edits to have it show on other themes , but when you choose to change theme , it says "error on page" at the bottom and doesnt change
here is a copy I sent in PM to someone who asked the same thing
-- note: regarding the quick theme changer. thanks go to Hambil who shared this mod with the SMF family
http://custom.simplemachines.org/mods/index.php?mod=746
I modified it. To add it to your OTHER THEMES so you can switch between them and seemer based themes
or this custom theme:
in the index.php of your forum folder, look for:
// Start the session. (assuming it hasn't already been.)
loadSession();
then AFTER that insert this:
// -- QUICK THEME CHANGER START
// Load the themes for the Quick Theme Changer downdown
$request = db_query("
SELECT ID_THEME, variable, value
FROM {$db_prefix}themes
WHERE variable IN ('name', 'theme_dir', 'theme_url', 'images_url')
AND ID_MEMBER = 0", __FILE__, __LINE__);
$context['themes'] = array();
while ($row = mysql_fetch_assoc($request))
{
if (!isset($context['themes'][$row['ID_THEME']]))
$context['themes'][$row['ID_THEME']] = array(
'id' => $row['ID_THEME'],
);
$context['themes'][$row['ID_THEME']][$row['variable']] = $row['value'];
}
mysql_free_result($request);
// -- QUICK THEME CHANGER END
now for each theme
now, in the index.template.php that you wish to have a theme changer, look for the section where the
copyright is displayed at the bottom of the screen. You should see above that part, where a script command
ends, and a new table begins.
// ]]></script>
<table cellspacing="0" cellpadding="3" border="0" align="center" width="100%">
<tr>
under the </script> insert this part
<!-- // Quick Theme Changer Script -->
<script language="JavaScript" type="text/javascript">
function quick_theme_changer(obj)
{
var id = obj.options[obj.selectedIndex].value;
var url = new String(window.location);
loc = \'index.php?theme=\' + id + \';saa=quick\' + \';url=\' + escape(url);
window.location = loc;
}
</script>
<!-- // Quick Theme Changer End -->
if your theme has been altered, you are looking to insert the theme changer code BETWEEN the <table>
and the <tr>. so insert this:
<!-- // Quick Theme Changer Start -->
<tr>
<td colspan="3" style="text-align: center;">
<select class="skin_changer" name="quick_theme_changer" onchange="quick_theme_changer(this)">
<optgroup label="', $txt['quick_theme_changer'], '">';
foreach ($context['themes'] as $theme)
{
echo '<option value="', $theme['id'], '"', (($settings['theme_id'] == $theme['id']) ? 'selected="selected"' : ''), '>', $theme['name'], '</option>';
}
echo '</optgroup>
</select>
</td>
</tr>
<!-- // Quick Theme Changer End -->
you know how to make sure you have an echo ' when needed? or to shut off echo with a '; when needed? in case of errors like that?
its easy, I added it to all my themes in a few minutes, always make backups first.
I am working on a new theme and added the changer to it. if you want to make the changer in its own table here is the code I am using in a left sidebar:
echo '
<script language="JavaScript" type="text/javascript">
function quick_theme_changer(obj)
{
var id = obj.options[obj.selectedIndex].value;
var url = new String(window.location);
loc = \'index.php?theme=\' + id + \';saa=quick\' + \';url=\' + escape(url);
window.location = loc;
}
</script>
<table cellspacing="0" cellpadding="0" border="0" width="100%" align="center">
<tr>
<td class="sidebar_titles" align="center">';
echo , $txt['quick_theme_changer'], '<br />
</td></tr><tr>
<td>
<select class="skin_changer" name="quick_theme_changer" onchange="quick_theme_changer(this)">
<optgroup label="', $txt['quick_theme_changer'], '">';
foreach ($context['themes'] as $theme)
{
echo '<option style="text-align: left;" value="', $theme['id'], '"', (($settings['theme_id'] == $theme['id']) ? 'selected="selected"' : ''), '>', $theme['name'], '</option>';
}
echo '</optgroup>
</select>
</td>
</tr>
</table>';
hope these help..
nada
Hello there!
Great mod you made here. It works as it should, but unfortunately I get error messages in admin area under Maintainance -> Logged errors.
I run version 1.1.2. Any chance for at fix for this problem? That would be great. Thank you!
Here are some of the error messages I`ve gotten:
8: Undefined index: quick_theme_changer
Fil: /usr/home/web/webx/byggmuskler.no/forum/Themes/default/Admin.template.php (eval?)
Linje: 368
8: Undefined index: quick_theme_changer
Fil: /usr/home/web/webx/byggmuskler.no/forum/Themes/default/BoardIndex.template.php (eval?)
Linje: 368
8: Undefined index: quick_theme_changer
Fil: /usr/home/web/webx/byggmuskler.no/forum/Themes/default/Display.template.php (eval?)
Linje: 368
8: Undefined index: quick_theme_changer
Fil: /usr/home/web/webx/byggmuskler.no/forum/Themes/default/MessageIndex.template.php (eval?)
Linje: 368
8: Undefined index: quick_theme_changer
Fil: /usr/home/web/webx/byggmuskler.no/forum/Themes/default/Errors.template.php (eval?)
Linje: 368
Ladynada: How do I get the Theme Changer to appear if I install this mod manually after your example above? Do I have still have to import and activate the mod from inside admin first, and then apply the modifications? Excuse me, but I am not an expert on these sort of things. :(
Regards Iron IC
my reply crashed, good thing I copied and pasted it to a file before trying to save it. that can happen on any forum, so its a good habit to get into for long replies
Hi Iron IC,
I downloaded it again to refresh my memory. To manually add this with my modifications, I did NOT change Themes.php at all in the sources folder.
next: I DID add the code in the SMF folder's index.php and here is how mines looks after the edit.
// Start the session. (assuming it hasn't already been.)
loadSession();
// -- QUICK THEME CHANGER START
// Load the themes for the Quick Theme Changer downdown
$request = db_query("
SELECT ID_THEME, variable, value
FROM {$db_prefix}themes
WHERE variable IN ('name', 'theme_dir', 'theme_url', 'images_url')
AND ID_MEMBER = 0", __FILE__, __LINE__);
$context['themes'] = array();
while ($row = mysql_fetch_assoc($request))
{
if (!isset($context['themes'][$row['ID_THEME']]))
$context['themes'][$row['ID_THEME']] = array(
'id' => $row['ID_THEME'],
);
$context['themes'][$row['ID_THEME']][$row['variable']] = $row['value'];
}
mysql_free_result($request);
// -- QUICK THEME CHANGER END
// What function shall we execute? (done like this for memory's sake.)
That was an easy copy and paste
next:
there are two parts you need to add to the theme's Index.template.php. I agree with the author that the best place is at the bottom (once you get the hang of it you could put it in a sidebar like I did with my elijah theme).
In the earthmom theme which you could download to look at the code, I put the java script part right after the script code for the footarea. That spot starts where you will see:
// Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
right after where their script ends, paste in the script section from this theme changer mod like this:
// ]]></script>
<!-- // Quick Theme Changer Script -->
<script language="JavaScript" type="text/javascript">
function quick_theme_changer(obj)
{
var id = obj.options[obj.selectedIndex].value;
var url = new String(window.location);
loc = \'index.php?theme=\' + id + \';saa=quick\' + \';url=\' + escape(url);
window.location = loc;
}
</script>
<!-- // Quick Theme Changer End -->
insert the code from the mod AFTER this:
// ]]></script>
Be sure to use my code, and by the way, my changes will not make the theme change 'permanent' for the user, but only for that session.
last:
you need to put the code for the changer itself. And in the earthmom theme I 'inserted' the code as a <tr> .... </tr> section, inside the section before the SMF logos and stuff.
<tr>
<td colspan="3" style="text-align: center;">
<select class="skin_changer" name="quick_theme_changer" onchange="quick_theme_changer(this)">
<optgroup label="', $txt['quick_theme_changer'], '">';
foreach ($context['themes'] as $theme)
{
echo '<option value="', $theme['id'], '"', (($settings['theme_id'] == $theme['id']) ? 'selected="selected"' : ''), '>', $theme['name'], '</option>';
}
echo '</optgroup>
</select>
</td>
</tr>
So.. if you want, you can simply make your own table and use that <tr> .... </tr> section in it for the changer. Just be sure you have the java script section before it to avoid those index errors where a variable name is being referenced without being declared beforehand.
It is very easy. But I put the code in different places in my themes depending on how things changed as I made themes. So you could look at the code in any of my themes to get an idea.
So as not to confuse you, I will post in the next message, the code I used in my current elijah theme on my site, with the theme changer in the side bar.
nada
just another way to do it. all you need is the code from the mod entered into your SMF folder's index.php, like it says. Again, you do NOT need to change your Themes.php in the sources folder, as the theme change with my method will NOT be permanent for the user. Then for this example, here is the code I used in the sidebar on my current elijah theme at http://heartdaughter.com/
echo '
<script language="JavaScript" type="text/javascript">
function quick_theme_changer(obj)
{
var id = obj.options[obj.selectedIndex].value;
var url = new String(window.location);
loc = \'index.php?theme=\' + id + \';saa=quick\' + \';url=\' + escape(url);
window.location = loc;
}
</script>
<table cellspacing="0" cellpadding="0" border="0" width="100%" align="center">
<tr>
<td class="sidebar_titles" align="center">';
echo , $txt['quick_theme_changer'], '<br />
</td></tr><tr>
<td>
<select class="skin_changer" name="quick_theme_changer" onchange="quick_theme_changer(this)">
<optgroup label="', $txt['quick_theme_changer'], '">';
foreach ($context['themes'] as $theme)
{
echo '<option style="text-align: left;" value="', $theme['id'], '"', (($settings['theme_id'] == $theme['id']) ? 'selected="selected"' : ''), '>', $theme['name'], '</option>';
}
echo '</optgroup>
</select>
</td>
</tr>
</table>';
nada
OMG, I will need some time to try and understand all this stuff :) I wish I was as good at this as you are, and that`s VERY GOOD, obviously! Thanks a million! I will chime in again if I have any questions. I guess the only way to learn is trial and error!
Oh, wait! You didn`t answer all my questions: I still wonder if I need to install the original theme changer mod from inside admin for this to work?
You are saying this mod does not change theme permanent for the user, but does it allow guests to change the theme as well? I do not want guests to be able to change the theme...
Quote from: Iron IC on June 06, 2007, 06:15:33 PM
OMG, I will need some time to try and understand all this stuff :) I wish I was as good at this as you are, and that`s VERY GOOD, obviously! Thanks a million! I will chime in again if I have any questions. I guess the only way to learn is trial and error!
Oh, wait! You didn`t answer all my questions: I still wonder if I need to install the original theme changer mod from inside admin for this to work?
You are saying this mod does not change theme permanent for the user, but does it allow guests to change the theme as well? I do not want guests to be able to change the theme...
yes it does let guests change the theme. and no you do not, and should not install it from admin, if you add it manually like this.
Someone else will have to give a code fragment to test if the user is a guest and not allow them to actually change the theme. I am not as good at coding as you have said! :)
nada
Hello again! Oh, don`t be shy, you are at least much better than me at this coding stuff, that`s for sure, lol.
I am afraid I do not quit understand everything you said here, I guess you will have to spoonfeed it to me. One thing I managed myself though, was to edit Themes.php, so that the changes to the theme is permanent. I only used the first piece of code (see page 1 in this thread), and not the one that allows guests to change the theme. This is actually working, but this is before I even have tried your manual approach. I still get all the annoying error messages inside admin.
Isn`t there a simple way to get rid of these errors , as the mod are working nicely as it is? (Even though the errors don`t actually affect the function of the mod.)
I tried to apply your mod to the index.template and that made the changer disappear from the forum (but this was done while the mod was installed from admin, so I guess that`s why it happened.)
If I where to give this manual editing a try with your modifications, do I have to edit something to the mod`s .xml file too? In that case, please show me exactly what and where to edit code. PS! If you think I am a complete idiot, just tell me to forget the whole thing and I won`t bother you anymore. :-[
Thnx
Iron IC
Hi Iron IC,
No I do not think you are an idiot. I am wondering why you get those errors. You might have part of the code in your Index.template.php more than once.
For you to use my manual edit, you would have uninstall the mod through the admin. Also, I do not use the Themes.php modification at all. It is possible that the code there is causing your error, but I am not sure.
What I would do, is start all over and uninstall the mod, and check the files for any duplicate code from the mod and delete. OR if you made backups, you could go back to your backups.
Let me know what happens,
nada
You are to kind! Thank you very much. I`ll let you know what happens! (By the way, I get the errors with or without the themes.php modification so that`s not it) :)
I guess maybe the problem has to do with me running norwegian-utf8. I got the same kind of errors with the Order News mod. I got rid of them after copying the contents from Themes/default/languages/modifications.english.php into modifications.norwegian-utf8.php.
Problem is, there`s no modifications in modifications.english.php that has to do with the Quick Theme Changer, so I have no text to paste into the norwegian modfile. Maybe this info can make you understand what the problem is?
I checked for duplicate code, but it seem to be correct the way it is.
Iron IC
Quote from: Iron IC on June 07, 2007, 07:59:56 AM
You are to kind! Thank you very much. I`ll let you know what happens! (By the way, I get the errors with or without the themes.php modification so that`s not it) :)
basically that UNDEFINED error is due to some code trying to use a variable before the variable has been officially given a value.
It is like calling your 12 year old child by a name, when you never named him when he was born.
hope that helps you understand. it means you have, possibly, some code that the program sees BEFORE the code that tells the program the value for the named-variable that the error complains about.
by the way, PHP will sometimes still execute the program correctly! So, just because you see an undefined error that does not mean the program will not still work right, however it does mean that you should fix it, because your log will fill up, and the code is not right.
Hey charlie! dinner time!
charlie: who is charlie? everyone has called me junior ever since I was born, but I will come to dinner anyway!
nada
is there anyway to hide a particular theme? I dont want to show the SMF default theme to my usrs, is that possible?
Quote from: locomotion182 on June 07, 2007, 08:47:28 PM
is there anyway to hide a particular theme? I dont want to show the SMF default theme to my usrs, is that possible?
Well, in the admin panel, under THEMES AND SETTINGS, you can click next to the default theme so that the red X goes away, and then that theme will not be available, but the files will still be on your system.
hope this helps
nada
hmm
one question though if i do this, next time i add a mod, it wont be added to the SMF default theme right?
Im asking because as an Admin i want to keep it, to test the mods and everything.
Hello loco!
Yes, I think you are correct. The modifications are affecting the theme that is set to default.
thanks Iron IC,
believe it or not I have never added a mod through the admin, so I do not know what happens!
nada
Hehe, I believe you lady nada! The install function from admin works just fine! But as I said, the changes are being made to the forums default theme. Very often a mod doesn`t work if you attemt to install it on a different theme other than SMF default core. I think it is a good idea to always use SMF-core as default theme, unless you run a clean install without any modifications.
Quote from: Badboy on April 09, 2007, 10:33:36 AM
Great mod. But for users to send back to where they were and to allow guests to select theme...
First please install the original mod.
Then...
Open Themes.php
Find:
redirectexit('action=profile;sa=theme');
Replace with:
if (isset($_REQUEST['saa']) && $_REQUEST['saa'] == 'quick')
{
redirectexit($_REQUEST['url']);
}
else
{
redirectexit('action=profile;sa=theme');
}
Now we have to edit quick_theme_changer function.
So open index.template.php
Find:
var url = new String(window.location);
loc = \'index.php?action=theme;sa=pick;saa=quick;u=', $context['user']['id'] ,';th=\' + id + \';sesc=', $context['session_id'], ';url=\' + escape(url);
window.location = loc;
Replace with:
var url = new String(window.location);';
if (!$context['user']['is_guest'])
{
echo '
loc = \'index.php?action=theme;sa=pick;saa=quick;u=', $context['user']['id'] ,';th=\' + id + \';sesc=', $context['session_id'], ';url=\' + escape(url);
window.location = loc;';
}
else
{
echo '
loc = \'index.php?theme=\' + id;
window.location = loc;';
}
echo '
Now all the users will send back to where they were...
And guests can select theme...
I tried this approach and did it exactly as written above, after installing the original mod from admin first. BUT, why are the users sent to their profile and not to their present page as they are supposed to? I still get these anoying errors in my log. I would really like to know from someone what I can do to correct it.
I`m gonna give your solution another try nada! :)
Thanks.
Just chiming in to tell how things are going.
I have now FINALLY managed to get this thing working for all of my 13 themes! I used your "receipe" nada. :) Did not do anything to themes.php, and simply edited forum index.php and every themes index.template.php file.
It doesn`t work exactly like you said though. Guests can NOT change theme, but that was what I wanted so that`s just sweet. (In one of your first posts in this thread, you talked about editing Load.php. Am I supposed to?).
I would be really satisfied if I could make it so that the user is being sent back to where he was before changing the theme. Any clues? Now they end up on the main page or in their profile...
I got rid of the errors in the log, but only because I disabled it. lol.
YIKES!
You are right IRON IC, I did make that change in Load.php in the sources file, and thats how I got it to return you back to where you were. so, yes you need that. thank you.
nada
Lady Nada.... I think I LOVE YOU! :-*
That did the trick. Everything works like a charm :)
Thank you so very very much!
Iron IC
yay! that's great!
nada
Anyone know how to sort the themes in alphabetical order on the pulldown menu?
This doesnt want to work on my themes. It works on the default, but not my other ones. On the other ones, I can select a new skin, but it wont change....
Will this work on version 1.1.3?
now for each theme
now, in the index.template.php that you wish to have a theme changer, look for the section where the
copyright is displayed at the bottom of the screen. You should see above that part, where a script command
ends, and a new table begins.
// ]]></script>
<table cellspacing="0" cellpadding="3" border="0" align="center" width="100%">
<tr>
under the </script> insert this part
<!-- // Quick Theme Changer Script -->
<script language="JavaScript" type="text/javascript">
function quick_theme_changer(obj)
{
var id = obj.options[obj.selectedIndex].value;
var url = new String(window.location);
loc = \'index.php?theme=\' + id + \';saa=quick\' + \';url=\' + escape(url);
window.location = loc;
}
</script>
<!-- // Quick Theme Changer End -->
if your theme has been altered, you are looking to insert the theme changer code BETWEEN the <table>
and the <tr>. so insert this:
<!-- // Quick Theme Changer Start -->
<tr>
<td colspan="3" style="text-align: center;">
<select class="skin_changer" name="quick_theme_changer" onchange="quick_theme_changer(this)">
<optgroup label="', $txt['quick_theme_changer'], '">';
foreach ($context['themes'] as $theme)
{
echo '<option value="', $theme['id'], '"', (($settings['theme_id'] == $theme['id']) ? 'selected="selected"' : ''), '>', $theme['name'], '</option>';
}
echo '</optgroup>
</select>
</td>
</tr>
<!-- // Quick Theme Changer End -->
you know how to make sure you have an echo ' when needed? or to shut off echo with a '; when needed? in case of errors like that?
its easy, I added it to all my themes in a few minutes, always make backups first.
[/quote]
Screaming I can't find this section!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
Never mind I am so sick of messing with this. Nothing in my themes shows a copyright area nor an ending script section.
The more I mess with it the more ticked off I become.
I need a magic wand. LOL
QuoteAn Error Has Occurred!
You cannot download or install new packages because the Packages directory or one of the files in it are not writable!
I get this with all my packages. I tried to install the first one and it asked me for ftp information so I gave it. Then after that any package I tried to install gives the error. Also the first pack doesn't appear to work. I have version 1.4.1. Any help would be very welcome.
You can change those permissions with your ftp client.
i have, i have chmodded the entire dircetory and every single file individually to 0777 in fire ftp and again in dream weaver to 777. I tried using a different computer but still no luck
@ MadnessRed
Your query is not specific to this mod and is thus off topic...if you need further advice on its resolution please post to General English support.
The most likely resolutions are to add a "temp" (sans quotes) directory to your Packages directory and CHMOD it to 777 and if that doesn't resolve the problem to go to ACP>Packages>Options and uncheck "Create Backup versions of replaced files with a tilda (~) on the end of their names."...N.B. when trying to input your ftp information on that screen please use the local path meaning what you see in the navigation breadcrumbs in your ftp client.
Can't this mod made like the style.css changer.
just like this topic http://www.simplemachines.org/community/index.php?topic=102787.0
(to see the codes, get to the 5th message)
but then like a mod.
sow the dropdown box only let you choose another XXXX_style.css
and how can I change the place off the dropdownbox to underneath the menu?
Is this mod known to work with SMF 1.1.5 ? Thanks
Trinny and MadnessRed's errors are probably both because there's a subdirectory in the ZIP file. The attached file is using the methodology of all of the other mods I've seen (no included subdirectory) which oughta fix both problems. O:)
The parser I used had a similar error to Trinny's until I got rid of the subdir. I've seen the Package Installer get stuck in that weird FTP loop when it's trying to chmod a file or directory that doesn't exist. The most likely cause is the subdir in the original ZIP, but it would also happen if you didn't have $languagedir/index.english.php on your forum.
And yeah, it works just fine with 1.1.5. You still have to manually add it in to all of your other themes that have their own unique index.template.php, though.
Hi All,
My Forum version was 1.1.5, just updated to 1.1.6.
I installed the quick theme select mod, it works great, no major issues at all.
1 minor issue, is there a way to code edit it so it does not show on the outside of the forum when logged off?.
If so, what code do I need to edit and where?.
Thanks.
antechinus reply was: Yep. Presumably it has an echo' before the changer code so you just add if($context['user']['is_logged']) before that.
I'm assuming that code would be in index.template but you really should ask in the mod thread. The person who made the thing will know.
he didnt say where to add it, as in: Find?? replace with??.
Any help would be awesome thanks.
In index.template.php find
<!-- // Quick Theme Changer Start -->
replace it with
';
if($context['user']['is_logged']){
echo '
<!-- // Quick Theme Changer Start -->
and replace
<!-- // Quick Theme Changer End -->
with
<!-- // Quick Theme Changer End -->';
}
echo '
Awesome, That worked perfect.
Thanks for the help and assistance.
So... This mod works on the 1.1.6 board Default Style. However, I tried to add it to the other styles, and I couldn't for the life of me figure it out. Could you help me out? File is attached. Also, would I need to modify any other files in this style?
Hello?
Works great on 1.1.7, working on 4 themes :)
I found a fix for keeping non-admin users on the same page!
Open /Sources/Themes.php
Find:
// Save for this user.
if (!isset($_REQUEST['u']) || !allowedTo('admin_forum'))
{
updateMemberData($ID_MEMBER, array('ID_THEME' => (int) $_GET['th']));
redirectexit('action=profile;sa=theme');
Replace with:
// Save for this user.
if (!isset($_REQUEST['u']) || !allowedTo('admin_forum'))
{
updateMemberData($ID_MEMBER, array('ID_THEME' => (int) $_GET['th']));
redirectexit($_REQUEST['url']);
I'm not sure why or how it works, but it does. I was just tinkering around and trying anything. I have been using it for a few days now and haven't found any problems.
I'm seeming to have trouble with this mod. Whenever I try to edit the index.template.php on some skins, some or all of the code is missing that is needed to be changed. Whenever I edit what is there, the skin breaks, and if I leave it the mod doesn't work on the skin. How do I make it work on the skins?
Quote from: fuddes on June 21, 2007, 02:04:34 PM
Anyone know how to sort the themes in alphabetical order on the pulldown menu?
I was wondering the same.
And also there is no option to go back to the forum or board default. If you want to do that you have to go into your profile "Look and Layout Preferences" and change to the default from there. I'm running SMF 1.1.8.
I'll take a look a the code and see if I can figure out a mod.
Since development on this modification stopped quite a while ago, I'll go ahead and post that there's been a new mod put out that does the same thing and also supports 2.0 (and 1.1.8 )... http://custom.simplemachines.org/mods/index.php?mod=1342
Quote from: Fustrate on April 25, 2009, 07:00:19 PM
Since development on this modification stopped quite a while ago, I'll go ahead and post that there's been a new mod put out that does the same thing and also supports 2.0 (and 1.1.8 )... http://custom.simplemachines.org/mods/index.php?mod=1342
I tried that one, and it added the field, but it didn't work at all. Don't know why, so I tried the SMF Quick Theme Changer which works fine for me.
I solved the alpha sort and the board default mod, and am writing up the mod now.
edit:
I'm going to test for a few days before posting the mod, but you can preview it on my site (http://www.somebandsilike.com). It doesn't allow you to actually change the theme unless you are registered, but you can see the Default option and alpha sort in the dropdown.
If you install Pretty URLs, it breaks the SMF Quick Theme Changer when trying to change themes when in a forum (404 error).
edit:
ahhh.. the fix is not working right when a regular user..
edit2:
Ok got it working hopefully..
The admin vs. regular user issue was relatively easy to fix. The redirect code in themes.php just needs to be in two places now. Not sure if that's a SMF 1.1.8 thing or Pretty URLs caused it.
While testing some more, a real bugger popped up when one of my topics had the word "they've" in it. More 404 errors when changing a theme while viewing the topic.
The cause was the redirect code in themes.php- the $_REQUEST['url'] function was not properly decoding single quote characters in the Pretty URLs url passed by the javascript function. It was decoding it as \\'
Bizarre...
I tried the other javascript url encode functions besides escape(url), but the single quote char always got mangled by $_REQUEST.
I finally figured out to use the str_replace function in the redirect, and to get that working took some head scratching:
redirectexit(str_replace('\\\\'',chr(39),$_REQUEST['url']));
Heh.
I'll post the full mod after a few more days of testing.
Ok it's been running fine with no issues, so here's the alpha sort, default theme at top of dropdown mod (plus fixes for non pretty and Pretty URLs):
Note I run SMF v1.1.8, so I have no idea if this will work on 2.X.
I also run Pretty URLs v0.9.2 (see notes below):
Find in /index.php:
// -- QUICK THEME CHANGER START
// Load the themes for the Quick Theme Changer downdown
$request = db_query("
SELECT ID_THEME, variable, value
FROM {$db_prefix}themes
WHERE variable IN ('name', 'theme_dir', 'theme_url', 'images_url')
AND ID_MEMBER = 0", __FILE__, __LINE__);
$context['themes'] = array();
while ($row = mysql_fetch_assoc($request))
{
if (!isset($context['themes'][$row['ID_THEME']]))
$context['themes'][$row['ID_THEME']] = array(
'id' => $row['ID_THEME'],
);
$context['themes'][$row['ID_THEME']][$row['variable']] = $row['value'];
}
mysql_free_result($request);
// -- QUICK THEME CHANGER END
Replace with:
This code I found in one of the other SMF php files. The ORDER BY value does the alpha sort. Note the original query code seems to be loading extra stuff into the array, that as far as I can tell, is never used.
// -- QUICK THEME CHANGER START modified
// Load all the theme IDs and names in alphabetical order
$request = db_query("
SELECT ID_THEME, value AS name
FROM {$db_prefix}themes
WHERE variable = 'name'
AND ID_MEMBER = 0
ORDER BY value", __FILE__, __LINE__);
$context['themes'] = array();
// add option for Forum or Board Default (at the top of the dropdown list)
$context['themes'][] = array(
'id' => 0,
'name' => 'Reset to Defaults'
);
while ($row = mysql_fetch_assoc($request))
{
$context['themes'][] = array(
'id' => $row['ID_THEME'],
'name' => $row['name']
);
}
mysql_free_result($request);
// -- QUICK THEME CHANGER END
Non Pretty URLs code fixes (note I didn't test this, as I run only Pretty URLs, post if it doesn't work):
If you get an odd page redirect as a non admin user (to the profile I think) when changing themes you may need this (note that fuddes mentioned this fix in a previous post above, and may only be needed with later SMF versions, like 1.1.8 ) :
Find in /Sources/Themes.php:
redirectexit('action=profile;sa=theme');
Replace with:
if (isset($_REQUEST['saa']) && $_REQUEST['saa'] == 'quick')
redirectexit($_REQUEST['url']);
else
redirectexit('action=profile;sa=theme');
Pretty URLs v0.9.2 code fixes (may not be needed with v0.9.3):
If you get an odd page redirect as a non admin user (to the profile I think) when changing themes or a 404 error if a single quote char is in the topic title you may need this:
Find in /Sources/Themes.php:
redirectexit('action=profile;sa=theme');
Replace with:
//odd str_replace code is to handle single quote chars in url not being properly decoded by $_REQUEST....
if (isset($_REQUEST['saa']) && $_REQUEST['saa'] == 'quick')
redirectexit(str_replace('\\\\'',chr(39),$_REQUEST['url']));
else
redirectexit('action=profile;sa=theme');
Find in /Sources/Themes.php:
redirectexit($_REQUEST['url']);
Replace with:
redirectexit(str_replace('\\\\'',chr(39),$_REQUEST['url']));
404 error fix:
Find in /Themes/default/index.template.php (or wherever yours is):
loc = \'index.php?action=theme;sa=pick;saa=quick;u=', $context['user']['id'] ,';th=\' + id + \';sesc=', $context['session_id'], ';url=\' + escape(url);
Replace with:
loc = \'', $scripturl, '?action=theme;sa=pick;saa=quick;u=', $context['user']['id'] ,';th=\' + id + \';sesc=', $context['session_id'], ';url=\' + escape(url);
Post if it does or doesn't work!