• Welcome to Simple Machines Community Forum. Please login or sign up.
December 09, 2021, 09:35:32 AM

News:

Check out the SMF Function DB!


Hiding a theme

Started by 1MileCrash, August 02, 2005, 04:16:06 PM

Previous topic - Next topic

1MileCrash

August 02, 2005, 04:16:06 PM Last Edit: August 03, 2005, 08:49:38 PM by Tippmaster
This is Blocs work, im just posting it for anyone who may find it useful

This will hide any theme of your choice from the theme selection. This will come in handy if you are developing a theme, and want to keep it hidden for the time being, without denying your users the abilty to choose their style. They can still access the style by url though. It also came in handy for the way i am integrating my forum into my site.

in Themes.template.php, find-
// This template allows for the selection of different themes ;).
function template_pick()
{
        global $context, $settings, $options, $scripturl, $txt;

        // Just go through each theme and show its information - thumbnail, etc.
        foreach ($context['available_themes'] as $theme)
                echo '
        <table align="center" width="85%" cellpadding="3" cellspacing="0" border="0" class="tborder">
                <tr class="', $theme['selected'] ? 'windowbg' : 'windowbg2', '">
                        <td rowspan="2" width="126" height="120"><img src="', $theme['thumbnail_href'], '" alt="" /></td>
                        <td valign="top" style="padding-top: 5px;">
                                <div style="font-size: larger; padding-bottom: 6px;"><b><a href="', $scripturl, '?action=theme;sa=pick;u=', $context['current_member'], ';th=', $theme['id'], ';sesc=', $context['session_id'], '">', $theme['name'], '</a></b></div>
                                ', $theme['description'], '
                        </td>
                </tr>
                <tr class="', $theme['selected'] ? 'windowbg' : 'windowbg2', '">
                        <td valign="bottom" align="right" style="padding: 6px; padding-top: 0;">
                                <div style="float: left;" class="smalltext"><i>', $theme['num_users'], ' ', ($theme['num_users'] == 1 ? $txt['theme_user'] : $txt['theme_users']), '</i></div>
                                <a href="', $scripturl, '?action=theme;sa=pick;u=', $context['current_member'], ';th=', $theme['id'], ';sesc=', $context['session_id'], '">', $txt['theme_set'], '</a> |
                                <a href="', $scripturl, '?action=theme;sa=pick;u=', $context['current_member'], ';theme=', $theme['id'], ';sesc=', $context['session_id'], '">', $txt['theme_preview'], '</a>
                        </td>
                </tr>
        </table>
        <br />';
}


replace that with

// This template allows for the selection of different themes ;).
function template_pick()
{
        global $context, $settings, $options, $scripturl, $txt;

        $hidden_themeID= "X";

        // Just go through each theme and show its information - thumbnail, etc.
        foreach ($context['available_themes'] as $theme){
          if($theme['id'] != $hidden_themeID)
                echo '
        <table align="center" width="85%" cellpadding="3" cellspacing="0" border="0" class="tborder">
                <tr class="', $theme['selected'] ? 'windowbg' : 'windowbg2', '">
                        <td rowspan="2" width="126" height="120"><img src="', $theme['thumbnail_href'], '" alt="" /></td>
                        <td valign="top" style="padding-top: 5px;">
                                <div style="font-size: larger; padding-bottom: 6px;"><b><a href="', $scripturl, '?action=theme;sa=pick;u=', $context['current_member'], ';th=', $theme['id'], ';sesc=', $context['session_id'], '">', $theme['name'], '</a></b></div>
                                ', $theme['description'], '
                        </td>
                </tr>
                <tr class="', $theme['selected'] ? 'windowbg' : 'windowbg2', '">
                        <td valign="bottom" align="right" style="padding: 6px; padding-top: 0;">
                                <div style="float: left;" class="smalltext"><i>', $theme['num_users'], ' ', ($theme['num_users'] == 1 ? $txt['theme_user'] : $txt['theme_users']), '</i></div>
                                <a href="', $scripturl, '?action=theme;sa=pick;u=', $context['current_member'], ';th=', $theme['id'], ';sesc=', $context['session_id'], '">', $txt['theme_set'], '</a> |
                                <a href="', $scripturl, '?action=theme;sa=pick;u=', $context['current_member'], ';theme=', $theme['id'], ';sesc=', $context['session_id'], '">', $txt['theme_preview'], '</a>
                        </td>
                </tr>
        </table>
        <br />';
        }
}


replace "X" with the id to the theme you want to be hidden. It will no longer apear under theme selection.

Thanks Bloc, this helped me a ton.  :)


The only thing php can't do is tell you how much milk is left in the fridge.



bloc

I have tested this and its nothing wrong with it. Themes change as they should.

1MileCrash

August 03, 2005, 12:32:27 PM #2 Last Edit: August 03, 2005, 12:47:34 PM by Tippmaster
 when i go to change themes, and click "Use this theme", it refreshes the page. Ill try again and post what happens.  :)


EDIT: nope, no good. I cant get it to work....did i put it in the wrong place or something?

Quote// --></script>';
}

// This template allows for the selection of different themes ;).
function template_pick()
{
        global $context, $settings, $options, $scripturl, $txt;

        $hidden_themeID= 2;

        // Just go through each theme and show its information - thumbnail, etc.
        foreach ($context['available_themes'] as $theme){
          if($theme['id'] != $hidden_themeID)
                echo '
        <table align="center" width="85%" cellpadding="3" cellspacing="0" border="0" class="tborder">
                <tr class="', $theme['selected'] ? 'windowbg' : 'windowbg2', '">
                        <td rowspan="2" width="126" height="120"><img src="', $theme['thumbnail_href'], '" alt="" /></td>
                        <td valign="top" style="padding-top: 5px;">
                                <div style="font-size: larger; padding-bottom: 6px;"><b><a href="', $scripturl, '?action=theme;sa=pick;u=', $context['current_member'], ';th=', $theme['id'], ';sesc=', $context['session_id'], '">', $theme['name'], '</a></b></div>
                                ', $theme['description'], '
                        </td>
                </tr>
                <tr class="', $theme['selected'] ? 'windowbg' : 'windowbg2', '">
                        <td valign="bottom" align="right" style="padding: 6px; padding-top: 0;">
                                <div style="float: left;" class="smalltext"><i>', $theme['num_users'], ' ', ($theme['num_users'] == 1 ? $txt['theme_user'] : $txt['theme_users']), '</i></div>
                                <a href="', $scripturl, '?action=theme;sa=pick;u=', $context['current_member'], ';th=', $theme['id'], ';sesc=', $context['session_id'], '">', $txt['theme_set'], '</a> |
                                <a href="', $scripturl, '?action=theme;sa=pick;u=', $context['current_member'], ';theme=', $theme['id'], ';sesc=', $context['session_id'], '">', $txt['theme_preview'], '</a>
                        </td>
                </tr>
        </table>
        <br />';
        }
}

// Okay, that theme was installed successfully!
function template_installed()
{
   global $context, $settings, $options, $scripturl

and, a test account:
Username: Test
Password: Test

How original :P

board url
The only thing php can't do is tell you how much milk is left in the fridge.



bloc

August 03, 2005, 01:26:50 PM #3 Last Edit: August 03, 2005, 01:29:36 PM by Bloc
ah, I think its because that code is meant for SMF 1.1beta3, not smf1.0.5 as you have.

Sorry, I should checked with you about that. Here is the code for the 1.0.5:

// This template allows for the selection of different themes ;).
function template_pick()
{
        global $context, $settings, $options, $scripturl, $txt;

        $hidden_themeID= "2";
        // Just go through each theme and show its information - thumbnail, etc.
        foreach ($context['available_themes'] as $theme){
           if($theme['id'] != $hidden_themeID)
                echo '
        <table align="center" width="85%" cellpadding="3" cellspacing="0" border="0" class="tborder">
                <tr class="', $theme['selected'] ? 'windowbg' : 'windowbg2', '">
                        <td rowspan="2" width="126" height="120"><img src="', $theme['thumbnail_href'], '" alt="" /></td>
                        <td valign="top" style="padding-top: 5px;">
                                <div style="font-size: larger; padding-bottom: 6px;"><b><a href="', $scripturl, '?action=theme;sa=pick;u=', $context['current_member'], ';id=', $theme['id'], ';sesc=', $context['session_id'], '">', $theme['name'], '</a></b></div>
                                ', $theme['description'], '
                        </td>
                </tr>
                <tr class="', $theme['selected'] ? 'windowbg' : 'windowbg2', '">
                        <td valign="bottom" align="right" style="padding: 6px; padding-top: 0;">
                                <div style="float: left;" class="smalltext"><i>', $theme['num_users'], ' ', ($theme['num_users'] == 1 ? $txt['theme_user'] : $txt['theme_users']), '</i></div>
                                <a href="', $scripturl, '?action=theme;sa=pick;u=', $context['current_member'], ';id=', $theme['id'], ';sesc=', $context['session_id'], '">', $txt['theme_set'], '</a> |
                                <a href="', $scripturl, '?action=theme;sa=pick;u=', $context['current_member'], ';theme=', $theme['id'], ';sesc=', $context['session_id'], '">', $txt['theme_preview'], '</a>
                        </td>
                </tr>
        </table>
        <br />';
  }
}


Haven't got to test it though, but it maybe that whats causing this error. The main difference between it , is that in 1.1 "th=" is used, while in 1.0.5 "id=" is used instead.

1MileCrash

that worked! Just a simple misunderstanding. Thanks for that.  :D
The only thing php can't do is tell you how much milk is left in the fridge.



Gargoyle

What if you want to dissallow more than one theme ?

Can you add comma's like this... 2,4 ??

1MileCrash

no. That wont work, because it will try to hide a theme with an id of 2, 4 (example), and it wont hide any. I tried it, and it unhid the one i had hidden.

Ill wait for someone to come up with a solution, because i dont know much about php.
The only thing php can't do is tell you how much milk is left in the fridge.



Lucas3677

$hidden_themeID = array('1', '2');

and then:

if(!in_array($theme['id'], $hidden_themeID))

Problem solved.

1MileCrash

That guy Tippmaster is such a moron.
The only thing php can't do is tell you how much milk is left in the fridge.



Cynthia Blue

Okay cool but... where is Themes.template.php in the directory tree?
Thanks.

1MileCrash

The only thing php can't do is tell you how much milk is left in the fridge.



unrelenting

This works well, BUT if you go to the screen where you choose your theme and hit one of the preview buttons it will show you that same screen using the chosen theme to preview it and THEN it won't be hiding the hidden themes. You can change to the hidden theme as well.  :-\

codenaught

Well keep in mind that this only hides the theme from being displayed on the theme listing page.

Quote
This will hide any theme of your choice from the theme selection. This will come in handy if you are developing a theme, and want to keep it hidden for the time being, without denying your users the abilty to choose their style. They can still access the style by url though. It also came in handy for the way i am integrating my forum into my site.

In no sense will this prevent users from changing their theme, they can even do it via url. Also I wasn't able to see the disabled theme myself when I selected to preview one of the themes.

In any case, I would say this tip may be a bit deprecated now that there is this mod - http://custom.simplemachines.org/mods/index.php?mod=391. Have you tried it out? This will not only hide the themes you want from being displayed but should also prevent the themes from being used at all. :)
Dev Consultant
Former SMF Doc Coordinator

unrelenting

Nice. No, I didn't know that was available. Thanks.

Mr Blah Man

November 24, 2007, 06:46:46 PM #14 Last Edit: November 24, 2007, 07:29:12 PM by Mr Blah Man
I only know Java but even I know you can just make it:

$hidden_themeID= "1" || $hidden_themeID= "2";

The || means AND. You'd porbably be able to do && as well which means AND.

So its saying:

The hidden theme IDs are: ThemeID 1 AND/OR ThemeID 2.

bloc

In fact "||" means OR, while "&&" means AND. The statement will be true if either of the id's are correct. But it makes no sense to set AND there, a variable cannot be two different values at the same time!

Also..the syntax isn't correct in PHP, it will have to be:

if($hidden_themeID== "1" || $hidden_themeID== "2")

Advertisement: