Advertisement:

Theme Settings Block? Specific for different colorstyle for one theme?

Aloittaja skybreaker, heinäkuu 05, 2013, 11:14:49 AP

« edellinen - seuraava »

skybreaker

Hey guys, I need your help.

I got Idea from the Noize theme from DzinerStudio. The Theme itself has an option for choosing a colorstyle. It's changing the .css file based on the choosen one. I managed it to work for my theme. Change the loaded .css based on what you choose from the dropdown...

Now i want to create a block, where users can choose the differente colorstyles from a dropdown menu. But I don't want them to choose a whole Theme, because there is only this one.

In the admin menus I can change the style globally for all Users. Is there any way to get this to work per User? In a Block with a drop down menu?

Ricky.

SMF do allow user to choose style at user level, have enabled settings to allow users to choose their own theme , just check under profile , in look and layout area for any user.

skybreaker

Hey, my problem is, I don't want them to choose a theme, just want them to choose a different style by themself.

for example:

I would create 4 stylesheets: red, blue, yellow, green... but for the same base Theme. Just changing the header background and link color for example.
Like it works now, I have a dropdown box in the admin menu, with shows the four colors. choosing one and save will change the style for all members.

But I want to give them the option to use the color they want. I don't want to copy and paste the theme, change the file and use it a second (third and fourth theme) for ervery color.

Edit: if this is even possible :/

codenaught

I am a little lost at what exactly you want.

SMF does allow you to have one theme with multiple color variations by having multiple stylesheet files.

But you seem to already know that.

Is what you are asking is how to make it so that each color variation on the theme selection page on the user's profile is shown as if it was its own base theme?
Dev Consultant
Former SMF Doc Coordinator

IchBin™

IchBin™        TinyPortal

Antechinus

Yeah you can do this easily. You just need a basic php block (if using a portal) or you can stick it in your template.

I assume you're using 2.0.x and the theme variant system that is built into it (IchBin's first link). If that is the case, you can set up a changer like this....

Variant list goes up the top, using whatever names you like:

/* Sometimes, we see other colours without licking frogs. This is one of those times. */
$settings['theme_variants'] = array('Bronze', 'Darkside', 'Emerald', 'Hellfire', 'Jade', 'Opal', 'Pinkbitz', 'Ruby');
}

// The main sub template above the content.
function template_html_above()



You also need this up in head somewhere:

// Javascript for permanently changing variants from forum.
if (!$context['user']['is_guest'])
echo '
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
function set_theme_variant(variant)
{
smf_setThemeOption("theme_variant", variant, ', $settings['theme_id'], ', "' . $context['session_id'] . '");
}
// ]]></script>';

echo '



The visible changer thingy goes down in the markup, like this:

function template_body_above()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;

echo '
<div id="wrapper">
<div id="header">
<div id="logo">
<a href="'.$scripturl.'" title=""></a>
</div>';

// Changer thingy. Permanent selection without changing pages!
if (empty($context['theme_settings']['disable_user_variant']))
echo '
<ul class="changer">
<li class="changerB"><a href="' . $_SERVER['REQUEST_URL'] . (strpos($_SERVER['REQUEST_URL'], '.php?') !== false ? ';' : '?') . 'variant=Bronze" onclick="set_theme_variant(\'Bronze\');" >&nbsp;</a></li>
<li class="changerD"><a href="' . $_SERVER['REQUEST_URL'] . (strpos($_SERVER['REQUEST_URL'], '.php?') !== false ? ';' : '?') . 'variant=Darkside" onclick="set_theme_variant(\'Darkside\');" >&nbsp;</a></li>
<li class="changerE"><a href="' . $_SERVER['REQUEST_URL'] . (strpos($_SERVER['REQUEST_URL'], '.php?') !== false ? ';' : '?') . 'variant=Emerald" onclick="set_theme_variant(\'Emerald\');" >&nbsp;</a></li>
    <li class="changerH"><a href="' . $_SERVER['REQUEST_URL'] . (strpos($_SERVER['REQUEST_URL'], '.php?') !== false ? ';' : '?') . 'variant=Hellfire" onclick="set_theme_variant(\'Hellfire\');" >&nbsp;</a></li>
<li class="changerJ"><a href="' . $_SERVER['REQUEST_URL'] . (strpos($_SERVER['REQUEST_URL'], '.php?') !== false ? ';' : '?') . 'variant=Jade" onclick="set_theme_variant(\'Jade\');" >&nbsp;</a></li>
<li class="changerO"><a href="' . $_SERVER['REQUEST_URL'] . (strpos($_SERVER['REQUEST_URL'], '.php?') !== false ? ';' : '?') . 'variant=Opal" onclick="set_theme_variant(\'Opal\');" >&nbsp;</a></li>
<li class="changerP"><a href="' . $_SERVER['REQUEST_URL'] . (strpos($_SERVER['REQUEST_URL'], '.php?') !== false ? ';' : '?') . 'variant=Pinkbitz" onclick="set_theme_variant(\'Pinkbitz\');" >&nbsp;</a></li>         
<li class="changerR"><a href="' . $_SERVER['REQUEST_URL'] . (strpos($_SERVER['REQUEST_URL'], '.php?') !== false ? ';' : '?') . 'variant=Ruby" onclick="set_theme_variant(\'Ruby\');" >&nbsp;</a></li>
</ul>';

// Lotsa other stuff blah blah.
echo '
</div>
<div id="toolbar">
',template_menu(),'
</div>


As you can see, I stuck that one up in the header, but you can throw it in anywhere you like (info centre is another good place, IMO).

This will give session-dependent selection for guests, and permanent selection for logged-in members, without changing pages when they change stylesheets.

Advertisement: