Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Miraenda on April 27, 2005, 08:14:06 PM

Title: Theme picker at top
Post by: Miraenda on April 27, 2005, 08:14:06 PM
Hi,

I had a friend who has greater PHP skills than I do to help me add a theme picker to the very top of my forum.  I picked my beta forum as that is the one where I have a bunch of themes on it.  If you'd like to see the theme picker in action, it is at http://miraenda.com/

Now, I asked the friend if it would be okay for me to provide the code to the SMF community before he was going to do it, so this is also with his approval.  Here are the instructions he provided to me:

First, put the following in the Sources/Load.php file:

function theme_name(){
  global $db_prefix,$context,$scripturl;
$resultaa=db_query("
        SELECT * from {$db_prefix}themes WHERE `variable` = 'name' ORDER by `value`", __FILE__, __LINE__);
while($rowaa=mysql_fetch_array($resultaa)){
$theme_rowa=$rowaa['ID_THEME'];
$theme_row_namea=$rowaa['value'];
$context['theme_options']="".$context['theme_options']."<option value=\"$scripturl?theme=$theme_rowa\">$theme_row_namea</option>";
}
}


Then, add in the index.php file:
theme_name();
right after:
loadTheme();

Then, put the theme changer in a global file so you can change it for all your themes in one file, create a file called themechanger.php in the Themes directory. In the themechanger.php file put the following:
<?
global $context;
echo '<center><form name="jumpurl1" onSubmit="return jumpit()">
                <select size="1" name="jumpurl2">
                      '.$context['theme_options'].'
                </select>
                <input type="button" value="Change it!" onClick="jumpit()"></form></center>
                   <script>
                       function jumpit(){
                          window.location=document.jumpurl1.jumpurl2.value
                          return false
                       }
                   </script>';
?>


Now, for all the themes you want to have the theme changer on, you would put the following in the index.template.php file in each of the Theme folders:
global $boarddir;
require ''.$boarddir.'/Themes/themechanger.php';


The best location might be right after the <body>'; tag.

Now, if you want to put the code just directly into the theme file instead of having a global file do this instead:
In the index.template.php file in the themes you wish to have the theme change in put the following:
echo '<center><form name="jumpurl1" onSubmit="return jumpit()">
                <select size="1" name="jumpurl2">
                      '.$context['theme_options'].'
                </select>
                <input type="button" value="Change it!" onClick="jumpit()"></form></center>
                   <script>
                       function jumpit(){
                          window.location=document.jumpurl1.jumpurl2.value
                          return false
                       }
                   </script>';


And that's It!

Let me know if you anyone uses it and/or likes it (or if you have any issues with it working for that matter).

Have a Blessed Day :)
Title: Re: Theme picker at top
Post by: Nyx on April 27, 2005, 08:31:30 PM
very useful :)
Title: Re: Theme picker at top
Post by: dtm.exe on April 27, 2005, 08:44:58 PM
Thanks.  Maybe I'll try that on my website.

-Dan The Man
Title: Re: Theme picker at top
Post by: Kirby on April 28, 2005, 11:12:51 PM
Here is what I'd do

Open index.template.php
Scroll to the end, right before ?> and add:


// This neat function finds and returns info about all of our themes.
function getThemeData()
{
global $db_prefix, $user_info, $scripturl, $settings, $options, $modSettings;

$themes = array();

// Get all of our themes.
$request = db_query("
SELECT value, ID_THEME
FROM {$db_prefix}themes
WHERE variable = 'name'
AND ID_THEME != $settings[theme_id]" . (empty($modSettings['theme_default']) ? '
AND ID_THEME != 1' : '') . "
ORDER BY value", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
{
$themes[] = array(
'id' => $row['ID_THEME'],
'name' => $row['value'],
);
}
return $themes;
}


Then you can just add this to where you want your theme chooser:

// Simplify this..
$themes = getThemeData();

if (!empty($themes))
{
echo '
<form action="', $scripturl ,'" name="themeForm">
<select name="theme" name="jumpto" id="jumpto" onchange="if (this.selectedIndex > 0 &amp;&amp; this.options[this.selectedIndex].value) window.location.href = smf_scripturl + this.options[this.selectedIndex].value.substr(smf_scripturl.indexOf(\'?\') == -1 ? 0 : 1);">';

foreach($themes as $theme)
echo '
<option value="?theme=', $theme['id'] ,'">' .$theme['name'] . '</option>';

echo '
</select>
</form>';
}


Tested and working with latest 1.1 beta :)
Title: Re: Theme picker at top
Post by: Miraenda on April 28, 2005, 11:19:54 PM
I think mine works with 1.1 Beta 1 as that is what my board runs on anyway as well... :)
Title: Re: Theme picker at top
Post by: Kirby on April 28, 2005, 11:22:19 PM
Yeah I know, I just did changes more on the code side :)
I like the idea behind this "trick"..
Title: Re: Theme picker at top
Post by: Miraenda on April 28, 2005, 11:29:17 PM
Now if we can just get SMF to add something like this to a demo gallery of themes for this site ;)
Title: Re: Theme picker at top
Post by: Neol on May 01, 2005, 10:19:42 AM
Quote from: Kirby on April 28, 2005, 11:12:51 PM
Here is what I'd do

Open index.template.php
Scroll to the end, right before ?> and add:


// This neat function finds and returns info about all of our themes.
function getThemeData()
{
global $db_prefix, $user_info, $scripturl, $settings, $options, $modSettings;

$themes = array();

// Get all of our themes.
$request = db_query("
SELECT value, ID_THEME
FROM {$db_prefix}themes
WHERE variable = 'name'
AND ID_THEME != $settings[theme_id]" . (empty($modSettings['theme_default']) ? '
AND ID_THEME != 1' : '') . "
ORDER BY value", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
{
$themes[] = array(
'id' => $row['ID_THEME'],
'name' => $row['value'],
);
}
return $themes;
}


Then you can just add this to where you want your theme chooser:

// Simplify this..
$themes = getThemeData();

if (!empty($themes))
{
echo '
<form action="', $scripturl ,'" name="themeForm">
<select name="theme" name="jumpto" id="jumpto" onchange="if (this.selectedIndex > 0 &amp;&amp; this.options[this.selectedIndex].value) window.location.href = smf_scripturl + this.options[this.selectedIndex].value.substr(smf_scripturl.indexOf(\'?\') == -1 ? 0 : 1);">';

foreach($themes as $theme)
echo '
<option value="?theme=', $theme['id'] ,'">' .$theme['name'] . '</option>';

echo '
</select>
</form>';
}


Tested and working with latest 1.1 beta :)

Kirby, I used your code but there is a problem. There is a theme chooser, but no button to change after I have choose a theme!

Here is a screenshot.

Title: Re: Theme picker at top
Post by: Kirby on May 01, 2005, 12:37:35 PM
It should choose automatically, try...

adding this before ?>

// This neat function finds and returns info about all of our themes.
function getThemeData()
{
global $db_prefix, $user_info, $scripturl, $settings, $options, $modSettings;

$themes = array();

// Get all of our themes.
$request = db_query("
SELECT value, ID_THEME
FROM {$db_prefix}themes
WHERE variable = 'name'
AND ID_THEME != $settings[theme_id]" . (empty($modSettings['theme_default']) ? '
AND ID_THEME != 1' : '') . "
ORDER BY value", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
{
$themes[] = array(
'id' => $row['ID_THEME'],
'name' => $row['value'],
);
}
return $themes;
}


and this where you want the select box:

$themes = getThemeData();
// Super duper theme changer slash! :D
if (!empty($themes))
{
echo '
<form action="', $scripturl ,'" name="themeForm">
<select name="theme" onchange="if (this.selectedIndex > 0 &amp;&amp; this.options[this.selectedIndex].value) window.location.href = smf_scripturl + \'?theme=\' + this.options[this.selectedIndex].value.substr(smf_scripturl.indexOf(\'?\') == -1 ? 0 : 1);">';

foreach($themes as $theme)
echo '
<option value="', $theme['id'] ,'">' .$theme['name'] . '</option>';

echo '
</select>
<input type="submit" value="Change Themes!" />
</form>';
}


I updated a few things as well.
Title: Re: Theme picker at top
Post by: rolandog on May 05, 2005, 10:35:00 PM
God bless 1337 coders

:D
Title: Re: Theme picker at top
Post by: mank on June 01, 2005, 11:42:40 AM
I used Kirbys code on 1.1 beta 2 and it works a treat  ;D
Title: Re: Theme picker at top
Post by: Ohms on June 19, 2005, 12:30:44 AM
This is an excellent hack. I really needed it for my non-techie users to realize there actually were more themes. I did modify one thing, though:
I changed this:global $boarddir;
require ''.$boarddir.'/Themes/themechanger.php';

to
if ($modSettings['theme_allow']){   
    global $boarddir;
    require ''.$boarddir.'/Themes/themechanger.php';
    }


So if I turn off the ability for users to change their theme, the theme chooser is not shown at all.
Thanks a million for this!
Title: Re: Theme picker at top
Post by: nokonium on June 19, 2005, 05:15:40 AM
Quote from: ??? on May 01, 2005, 12:37:35 PM
It should choose automatically, try...

I updated a few things as well.

I've installed it in our 1.1beta2 test site, after the Search & Advanced Search. We have a range of colour variations based on the default theme. To allow anyone using a theme to select a new theme I have copied the indextemplate to each theme directory

It does choose automatically, on the selector on all except the first one in the list. If I use the button, it brings up the Search: in the selected theme. saying "Did you forget to put something to search for?"

If you then click the button, it does the same with the new first on the list. This one is OK when selected via the drop down.
Title: Re: Theme picker at top
Post by: bloc on June 19, 2005, 06:19:19 AM
Probably because the submit button in the theme form interfere with the search form. Did you put the code  inside the <form></form> for the search - or in a new form underneath?
Title: Re: Theme picker at top
Post by: nokonium on June 19, 2005, 06:53:07 AM
I pasted in exactly as above, which includes <form action..........  </form> and I inserted it immediately above // If we're on a certain board, limit it to this board ;).

This is the code of both forms

<form action="', $scripturl, '?action=search2" method="post" style="margin: 0; margin-top: 7px;">
<b>', $txt[182], ': </b><input type="text" name="search" value="" style="width: 175px;" />&nbsp;
<input type="submit" name="submit" value="', $txt[182], '" style="width: 8ex;" />&nbsp;
<a href="', $scripturl, '?action=search;advanced">', $txt['smf298'], '</a>
<input type="hidden" name="advanced" value="0" />';

$themes = getThemeData();
// Super duper theme changer slash! :D
if (!empty($themes))
{
echo '
<form action="', $scripturl ,'" name="themeForm">
<select name="theme" onchange="if (this.selectedIndex > 0 &amp;&amp; this.options[this.selectedIndex].value) window.location.href = smf_scripturl + \'?theme=\' + this.options[this.selectedIndex].value.substr(smf_scripturl.indexOf(\'?\') == -1 ? 0 : 1);">';

foreach($themes as $theme)
echo '
<option value="', $theme['id'] ,'">' .$theme['name'] . '</option>';

echo '
</select>
<input type="submit" value="Change Themes!" />
</form>';
}
Title: Re: Theme picker at top
Post by: bloc on June 19, 2005, 07:14:10 AM
Nokonium, you need to close the first form..add a </form> right after the "input type="hidden" name="advanced" value="0" />".

Title: Re: Theme picker at top
Post by: nokonium on June 19, 2005, 07:49:29 AM
Quote from: Bloc on June 19, 2005, 07:14:10 AM
Nokonium, you need to close the first form..add a </form> right after the "input type="hidden" name="advanced" value="0" />".


Thanks Bloc, that has sorted the search problem.

Unfortunately now they are on different lines. Is it possible to keep them on the same line?

I have saved the other code and may try it later, when I feel braver  ;)
Title: Re: Theme picker at top
Post by: bloc on June 19, 2005, 07:53:15 AM
That code had some error, so don't use it - yet. I will fix it later. :)

I don't think they can be on the same line..since forms are like div's ..maybe if you did a style="position: relative; float: right;" on the second form it might help?
Title: Re: Theme picker at top
Post by: nokonium on June 19, 2005, 08:01:29 AM
Quote from: Bloc on June 19, 2005, 07:53:15 AM
That code had some error, so don't use it - yet. I will fix it later. :)

I don't think they can be on the same line..since forms are like div's ..maybe if you did a style="position: relative; float: right;" on the second form it might help?

Thanks for the warning.

If that doesn't work, I'll see if I can put it underneath the Key stats or inside the User info, I'd like to try and keep it in the header.
Title: Re: Theme picker at top
Post by: Ohms on June 19, 2005, 12:31:12 PM
I forgot to mention that I was using Miraenda's code and that I also changed the code that was supposed to go in Sources/Load.php slightly. I changed it so that the current theme the member is using is the one selected in the dropdown menu:]// Quick theme changer
function theme_name(){
// Added $settings to the global definition
  global $settings,$db_prefix,$context,$scripturl;
$resultaa=db_query("
        SELECT * from {$db_prefix}themes WHERE `variable` = 'name' ORDER by `value`", __FILE__, __LINE__);
while($rowaa=mysql_fetch_array($resultaa)){
$theme_rowa=$rowaa['ID_THEME'];
$theme_row_namea=$rowaa['value'];
// Reset $selected to ""
$selected = "";
// Find the theme the member is currently using and set it to be the one selected in the form
if ($settings['theme_id'] == $theme_rowa){
   $selected = "selected";
   }
$context['theme_options']="".$context['theme_options']."<option value=\"$scripturl?theme=$theme_rowa\" $selected>$theme_row_namea</option>";
}
}

Title: Re: Theme picker at top
Post by: bloc on June 19, 2005, 12:46:09 PM
Nice, Ohms. :) Easier to see which theme you are watching, with current auto-selected.
Title: Re: Theme picker at top
Post by: Ohms on June 25, 2005, 07:32:47 PM
I just decided to add the Theme in Profile Mod and discovered that if they use the Quick Theme Changer to pick their theme, it did not get changed in their profile (e.g. the database), so I did some more tweaking with this.

The section in Load.php now looks like this:// Quick theme changer
function theme_name(){
  global $settings,$db_prefix,$context,$scripturl;
  $context['theme_options'] = "";
$resultaa=db_query("
        SELECT * from {$db_prefix}themes WHERE `variable` = 'name' ORDER by `value`", __FILE__, __LINE__);
while($rowaa=mysql_fetch_array($resultaa)){
$theme_rowa=$rowaa['ID_THEME'];
$theme_row_namea=$rowaa['value'];
$selected = "";
if ($settings['theme_id'] == $theme_rowa){
   $selected = "selected";
   }

$blech = $context['user']['id'];
$blech2 = $context['session_id'];
// $context['theme_options']="".$context['theme_options']."<option value=\"$scripturl?theme=$theme_rowa\" $selected>$theme_row_namea</option>";
$context['theme_options']="".$context['theme_options']."<option value=\"$scripturl?action=theme;sa=quickpick;u=$blech;id=$theme_rowa;sesc=$blech2\" $selected>$theme_row_namea</option>";
}
}


In Themes.php, near the top I changed:
$subActions = array(
'admin' => 'ThemeAdmin',
'settings' => 'SetThemeSettings',
'options' => 'SetThemeOptions',
'remove' => 'RemoveTheme',
'pick' => 'PickTheme',
'install' => 'ThemeInstall',
'edit' => 'EditTheme'
);

to:$subActions = array(
'admin' => 'ThemeAdmin',
'settings' => 'SetThemeSettings',
'options' => 'SetThemeOptions',
'remove' => 'RemoveTheme',
'pick' => 'PickTheme',
'quickpick' => 'QuickPick',
'install' => 'ThemeInstall',
'edit' => 'EditTheme'
);


Then I made a copy of the function PickTheme, calling it instead QuickPick and made some changes in the function [just replaced the 'redirectexit('blahblah')' code where you see my comments in two places with a javascript back() function]:
function QuickPick()
{
global $txt, $db_prefix, $sc, $context, $modSettings, $user_info, $ID_MEMBER, $language;

checkSession('get');

loadTemplate('Themes');
loadLanguage('Profile');

$_SESSION['ID_THEME'] = 0;

// Have we made a desicion, or are we just browsing?
if (isset($_GET['id']))
{
// Save for this user.
if (!isset($_REQUEST['u']) || !allowedTo('admin_forum'))
{
updateMemberData($ID_MEMBER, array('ID_THEME' => (int) $_GET['id']));
   // I changed redirectexit to this.
                   ?><script>
                       back()
                   </script><?php
                  
// End of this change. One more.
}
// For everyone.
elseif ($_REQUEST['u'] == '0')
{
updateMemberData(null, array('ID_THEME' => (int) $_GET['id']));

redirectexit('');
}
// Change the default/guest theme.
elseif ($_REQUEST['u'] == '-1')
{
updateSettings(array('theme_guests' => (int) $_GET['id']));

redirectexit('');
}
// Change a specific member's theme.
else
{
updateMemberData((int) $_REQUEST['u'], array('ID_THEME' => (int) $_GET['id']));
                   
// I changed redirectexit to this, too.      
                  
?>
<script>
                       back()
                   </script><?php
                  
// End of my change.
}
}

// Figure out who the member of the minute is, and what theme they've chosen.
if (!isset($_REQUEST['u']) || !allowedTo('admin_forum'))
{
$context['current_member'] = $ID_MEMBER;
$context['current_theme'] = $user_info['theme'];
}
// Everyone can't chose just one.
elseif ($_REQUEST['u'] == '0')
{
$context['current_member'] = 0;
$context['current_theme'] = 0;
}
// Guests and such...
elseif ($_REQUEST['u'] == '-1')
{
$context['current_member'] = -1;
$context['current_theme'] = $modSettings['theme_guests'];
}
// Someones else :P.
else
{
$context['current_member'] = (int) $_REQUEST['u'];

$request db_query("
SELECT ID_THEME
FROM 
{$db_prefix}members
WHERE ID_MEMBER = 
$context[current_member]
LIMIT 1"
__FILE____LINE__);
list ($context['current_theme']) = mysql_fetch_row($request);
mysql_free_result($request);
}
// Get the theme name and descriptions.
$context['available_themes'] = array();
if (!empty($modSettings['knownThemes']))
{
$knownThemes implode("', '"explode(','$modSettings['knownThemes']));

$request db_query("
SELECT ID_THEME, variable, value
FROM 
{$db_prefix}themes
WHERE variable IN ('name', 'theme_url', 'theme_dir', 'images_url')" 
. (empty($modSettings['theme_default']) && !allowedTo('admin_forum') ? "
AND ID_THEME IN ('
$knownThemes')
AND ID_THEME != 1" 
'') . "
AND ID_THEME != 0
LIMIT " 
count(explode(','$modSettings['knownThemes'])) * 4__FILE____LINE__);
while ($row mysql_fetch_assoc($request))
{
if (!isset($context['available_themes'][$row['ID_THEME']]))
$context['available_themes'][$row['ID_THEME']] = array(
'id' => $row['ID_THEME'],
'selected' => $context['current_theme'] == $row['ID_THEME'],
'num_users' => 0
);
$context['available_themes'][$row['ID_THEME']][$row['variable']] = $row['value'];
}
mysql_free_result($request);
}

// Okay, this is a complicated problem: the default theme is 1, but they aren't allowed to access 1!
if (!isset($context['available_themes'][$modSettings['theme_guests']]))
{
$context['available_themes'][0] = array(
'num_users' => 0
);
$guest_theme 0;
}
else
$guest_theme $modSettings['theme_guests'];

$request db_query("
SELECT COUNT(ID_MEMBER) AS theCount, ID_THEME
FROM 
{$db_prefix}members
GROUP BY ID_THEME DESC"
__FILE____LINE__);
while ($row mysql_fetch_assoc($request))
{
// Figure out which theme it is they are REALLY using.
if ($row['ID_THEME'] == && empty($modSettings['theme_default']))
$row['ID_THEME'] = $guest_theme;
elseif (empty($modSettings['theme_allow']))
$row['ID_THEME'] = $guest_theme;

if (isset($context['available_themes'][$row['ID_THEME']]))
$context['available_themes'][$row['ID_THEME']]['num_users'] += $row['theCount'];
else
$context['available_themes'][$guest_theme]['num_users'] += $row['theCount'];
}

foreach ($context['available_themes'] as $ID_THEME => $theme_data)
{
// Don't try to load the forum or board default theme's data... it doesn't have any!
if ($ID_THEME == 0)
continue;

$settings $theme_data;
$settings['theme_id'] = $ID_THEME;

if (file_exists($settings['theme_dir'] . '/languages/Settings.' $user_info['language'] . '.php'))
include($settings['theme_dir'] . '/languages/Settings.' $user_info['language'] . '.php');
elseif (file_exists($settings['theme_dir'] . '/languages/Settings.' $language '.php'))
include($settings['theme_dir'] . '/languages/Settings.' $language '.php');
else
{
$txt['theme_thumbnail_href'] = $settings['images_url'] . '/thumbnail.gif';
$txt['theme_description'] = '';
}

$context['available_themes'][$ID_THEME]['thumbnail_href'] = $txt['theme_thumbnail_href'];
$context['available_themes'][$ID_THEME]['description'] = $txt['theme_description'];
}

// As long as we're not doing the default theme...
if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0)
{
if ($guest_theme != 0)
$context['available_themes'][0] = $context['available_themes'][$guest_theme];
$context['available_themes'][0]['id'] = 0;
$context['available_themes'][0]['name'] = $txt['theme_forum_default'];
$context['available_themes'][0]['selected'] = $context['current_theme'] == 0;
$context['available_themes'][0]['description'] = $txt['theme_global_description'];
}

ksort($context['available_themes']);

$context['page_title'] = &$txt['theme_pick'];
$context['sub_template'] = 'pick';
}


The entire function probably didn't need to remain intact, but I figured I would err on the side of security and leave it in. If any PHP gurus out there can tell me what I can leave out, that would be awesome.

Doing it this way, the theme they are using gets updated in the database (e.g. their profile) and then they are redirected back to wherever they were when they changed the theme.

So, now the Theme in Profile Mod works with this as well.

This probably slows this down quite a bit.
Title: Re: Theme picker at top
Post by: LostProphecy on July 01, 2005, 12:30:07 AM
hmmm nice :)

i'll have to remember to try this out when i get home tonight :D
Title: Re: Theme picker at top
Post by: LostProphecy on July 04, 2005, 02:54:21 AM
looking at this it's quite massive... has anyone thought of making it a mod??
Title: Re: Theme picker at top
Post by: Terroriste on July 09, 2005, 12:44:23 PM
Thank you. You're best coder :)
Title: Re: Theme picker at top
Post by: IamV on July 23, 2005, 02:26:12 AM
I just tried Kirby's theme changer & it is the best I've tried so far!

It should be renamed 'The Ultimate Theme Changer/Selector'

Thank you so much for sharing this with us  ;D
Title: Re: Theme picker at top
Post by: LostProphecy on September 04, 2005, 05:48:16 AM
i'm generating this error all the time from the themechanger thingy...

8: Undefined index: theme_options
File: /home/kodee/public_html/forums/Themes/themechanger.php
Line: 5

can anyone help me in how you define "theme_options"
Title: Re: Theme picker at top
Post by: Escobar on September 13, 2005, 05:44:22 PM
Problem:
I have smf 1.05.
I tried this code.
I placed the second part in various places...but it doesn't show up.  :(
Any help?

EDIT (SOLUTION FOUND AFTER TINKERING):
I put it above
// Show the menu up top.  Something like [home] [help] [profile] [logout]...function template_menu()
and it showed up.

Next problem is having the change show up in the users profile...
I can't locate load.php and the other files ohms is talking about...



Title: Re: Theme picker at top
Post by: DemonicInfluence on September 17, 2005, 01:49:16 PM
Quote from: ashoka1 on September 13, 2005, 05:44:22 PM
Problem:
I have smf 1.05.
I tried this code.
I placed the second part in various places...but it doesn't show up.  :(
Any help?

EDIT (SOLUTION FOUND AFTER TINKERING):
I put it above
// Show the menu up top.  Something like [home] [help] [profile] [logout]...function template_menu()
and it showed up.

Next problem is having the change show up in the users profile...
I can't locate load.php and the other files ohms is talking about...




It is in the Sources folder..
Title: Re: Theme picker at top
Post by: barnjo on September 18, 2005, 04:53:29 PM
So where do I put the code that starts function QuickPick ()?
Title: Re: Theme picker at top
Post by: DemonicInfluence on September 19, 2005, 06:26:11 AM
themes.php
Title: Re: Theme picker at top
Post by: berserk87 on September 30, 2005, 03:46:49 AM
how do i put the theme chooser at the bottom of the page next to the xhtml, and css and myslq buttons and such?

were are they?
Title: Re: Theme picker at top
Post by: bloc on September 30, 2005, 04:51:29 AM
In index.template.php..look for <img id="powered-mysql"....etc. In default theme there is 3 <td>'s there.
Title: Re: Theme picker at top
Post by: Xarcell on October 23, 2005, 06:23:54 PM
I'm lost.
-------------------------------------------------------------
Instructions:
------------------------------------------------------------
Then, add in the index.php file:

theme_name();

right after:

loadTheme();

--------------------------------------------------------------

The Index file in the main smf directory right? I can't seem to find "theme_name();". My dropdown is blank.



-Xarcell, using 1.1rc1
Title: Re: Theme picker at top
Post by: bloc on October 23, 2005, 08:55:00 PM
No, find the second ("loadTheme") first and put the first("theme_name") after it...
Title: Re: Theme picker at top
Post by: Xarcell on October 23, 2005, 11:53:59 PM
I already tried adding "theme_name();" before the theme_load but all I got was an error.

<-- Session verification failed. Please try logging out and back in again, and then try again.-->

I did, but it still kept doing the same thing. Now I tried moving the "theme_name();" around a bit and can't egt it to do anything.

BTW, I must be blind, because I only see one "theme_load()" in the file. Thanx for your help though. I got frustrated and had to take a break. Now I'm back on it again, lol...

-Xarcell
Title: Re: Theme picker at top
Post by: Xarcell on October 24, 2005, 12:11:29 AM
Ok, I've tinkered with it a little more and it works now. However, after I select a theme, I have to refresh to get it to work. Or view the theme I picked.

Also, is there anyway to get the thumbnails of the theme to appear?

Thanx again,

EDIT: I thougt it would help to mention this, but I didn't use the global file/code for layout reasons, although the themechanger.php is in place. I used this



echo '<center><form name="jumpurl1" onSubmit="return jumpit()">
                <select size="1" name="jumpurl2">
                      '.$context['theme_options'].'
                </select>
                <input type="button" value="Change it!" onClick="jumpit()"></form></center>
                   <script>
                       function jumpit(){
                          window.location=document.jumpurl1.jumpurl2.value
                          return false
                       }
                   </script>';



I also used Ohms code suggestion for the load.php. theme.php, etc.

-Xarcell
Title: Re: Theme picker at top
Post by: bloc on October 24, 2005, 09:45:16 AM
In fact, my latest version of TinyPortal have a theme-chooser that show thumbnails of the themes... ;)

The code is tailored for TP though, with options to choose which themes should show in the chooser - so its not instantly appliable for "normal" themes/SMF.
Title: Re: Theme picker at top
Post by: DemonicInfluence on October 24, 2005, 06:01:23 PM
Could u show. So that we could try to modify it so it works normally?
Title: Re: Theme picker at top
Post by: Xarcell on October 24, 2005, 09:47:53 PM
Your a good man bloc.

I applied for beta testing TP.

-Xarcell
Title: Re: Theme picker at top
Post by: Az on October 28, 2005, 05:37:58 PM
Can anyone make this work with mambo too?
Title: Re: Theme picker at top
Post by: Xarcell on October 29, 2005, 10:49:37 PM
Is there a better code to use then this:



echo '<center><form name="jumpurl1" onSubmit="return jumpit()">
                <select size="1" name="jumpurl2">
                      '.$context['theme_options'].'
                </select>
                <input type="button" value="Change it!" onClick="jumpit()"></form></center>
                   <script>
                       function jumpit(){
                          window.location=document.jumpurl1.jumpurl2.value
                          return false
                       }
                   </script>';



Without using the global file? It just doesn't load the theme, I have to "refresh" to see what I selected on Firefox. On Internet Explorer, it takes me to the profile > theme selection page.
Title: Re: Theme picker at top
Post by: DemonicInfluence on October 30, 2005, 08:19:52 AM
you have to use quickpick.. You have to edit the themes.php file..
Title: Re: Theme picker at top
Post by: Xarcell on October 30, 2005, 01:27:14 PM
I did...

Exactly where do place the function code in the theme.php file?

Using rc1.

-Xarcell
Title: Re: Theme picker at top
Post by: DemonicInfluence on October 30, 2005, 06:26:19 PM
under the pick function...
Title: Re: Theme picker at top
Post by: Xarcell on October 30, 2005, 07:40:55 PM
Sorry for the misunderstanding, but I was talking about the part that started with:



function QuickPick()
{
Title: Re: Theme picker at top
Post by: DemonicInfluence on October 30, 2005, 07:59:13 PM
I still mean after function PickTheme() is over. Then.
you copy it and change the redirect and name.

I can give u my themes.php if u want
Title: Re: Theme picker at top
Post by: Gobo on April 29, 2006, 09:44:27 AM
so exactly which code do I need to use?

cos there are like 4 or 5 chunk of codes posted by different people....so which one is the best and safest with SMF 1.1rc2?

thanks
Title: Re: Theme picker at top
Post by: DemonicInfluence on April 29, 2006, 01:37:35 PM
Dunno what you mean by that. They are all safe... But I liked this one:

http://www.simplemachines.org/community/index.php?topic=34453.msg291361#msg291361
Title: Re: Theme picker at top
Post by: silverdragonrs on May 17, 2006, 01:52:35 AM
Ok this has gotten confusing.... Anybody mind putting all steps to this in one solid post? The original was a little confusing... and then the "better one" was cool... but it had problems?... and then several updates and edits to one or both.... hmm... this thread has gotten a little scattered... I (and most people i know) are not expert programmers... so one "tutorial" on this addin would be great... :) thanks,
danny
Title: Re: Theme picker at top
Post by: Vinspire on May 17, 2006, 06:19:38 AM
Quote from: akulion on April 29, 2006, 09:44:27 AM
so exactly which code do I need to use?

cos there are like 4 or 5 chunk of codes posted by different people....so which one is the best and safest with SMF 1.1rc2?

thanks

Same question here & can i have a screenshot of how does it look like ?
Title: Re: Theme picker at top
Post by: DemonicInfluence on May 17, 2006, 09:08:57 PM
Quote from: silverdragonrs on May 17, 2006, 01:52:35 AM
Ok this has gotten confusing.... Anybody mind putting all steps to this in one solid post? The original was a little confusing... and then the "better one" was cool... but it had problems?... and then several updates and edits to one or both.... hmm... this thread has gotten a little scattered... I (and most people i know) are not expert programmers... so one "tutorial" on this addin would be great... :) thanks,
danny

http://www.simplemachines.org/community/index.php?topic=26637.msg351367#msg351367

I have it posted. Should help..

Title: Re: Theme picker at top
Post by: Harro on February 20, 2007, 06:52:44 PM
My apologies for this necroposting :p
But anyone know if this still works for the current release?
Title: Re: Theme picker at top
Post by: Pieces on May 01, 2007, 08:47:51 AM
Quote from: Harro on February 20, 2007, 06:52:44 PM
My apologies for this necroposting :p
But anyone know if this still works for the current release?

I applied this to my forum last week.

Theme picker is working fine, though you have to keep in mind that the first part is missing the session stuff which Ohms describes. I didn't apply that part yet(so the chosen themes are not stored in the user profile yet :()

For the rest it's almost the same for 1.1.2