Advertisement:

Author Topic: Hiding a theme  (Read 32601 times)

Offline Tippmaster

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,188
Hiding a theme
« on: August 02, 2005, 04:16:06 PM »
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-
Code: [Select]
// 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

Code: [Select]
// 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.  :)


« Last Edit: August 03, 2005, 08:49:38 PM by Tippmaster »
The only thing php can't do is tell you how much milk is left in the fridge.



bloc

  • Guest
Re: Hiding a theme
« Reply #1 on: August 03, 2005, 12:23:21 PM »
I have tested this and its nothing wrong with it. Themes change as they should.

Offline Tippmaster

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,188
Re: Hiding a theme
« Reply #2 on: August 03, 2005, 12:32:27 PM »
 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
« Last Edit: August 03, 2005, 12:47:34 PM by Tippmaster »
The only thing php can't do is tell you how much milk is left in the fridge.



bloc

  • Guest
Re: Hiding a theme
« Reply #3 on: August 03, 2005, 01:26:50 PM »
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:

Code: [Select]
// 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.
« Last Edit: August 03, 2005, 01:29:36 PM by Bloc »

Offline Tippmaster

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,188
Re: Hiding a theme
« Reply #4 on: August 03, 2005, 01:36:18 PM »
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.



Offline Gargoyle

  • Sophist Member
  • *****
  • Posts: 1,148
  • Gender: Male
    • South Side Street Cars
Re: Hiding a theme
« Reply #5 on: August 03, 2005, 08:43:55 PM »
What if you want to dissallow more than one theme ?

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

Offline Tippmaster

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,188
Re: Hiding a theme
« Reply #6 on: August 03, 2005, 08:48:58 PM »
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.



Offline Lucas3677

  • Semi-Newbie
  • *
  • Posts: 20
Re: Hiding a theme
« Reply #7 on: August 03, 2005, 11:32:13 PM »
Code: [Select]
$hidden_themeID = array('1', '2');
and then:

Code: [Select]
if(!in_array($theme['id'], $hidden_themeID))
Problem solved.

Offline Tippmaster

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,188
Re: Hiding a theme
« Reply #8 on: August 03, 2005, 11:33:29 PM »
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.



Offline Cynthia Blue

  • Semi-Newbie
  • *
  • Posts: 60
  • Gender: Female
    • Tip Tail
Re: Hiding a theme
« Reply #9 on: August 10, 2005, 04:20:59 PM »
Okay cool but... where is Themes.template.php in the directory tree?
Thanks.

Offline Tippmaster

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,188
Re: Hiding a theme
« Reply #10 on: August 10, 2005, 04:30:09 PM »
it's in Themes/default

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



Offline unrelenting

  • Full Member
  • ***
  • Posts: 526
Re: Hiding a theme
« Reply #11 on: August 22, 2007, 09:54:12 PM »
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.  :-\

Offline codenaught

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,653
  • Gender: Male
  • Formerly Known As akabugeyes
Re: Hiding a theme
« Reply #12 on: August 22, 2007, 10:54:20 PM »
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

Offline unrelenting

  • Full Member
  • ***
  • Posts: 526
Re: Hiding a theme
« Reply #13 on: August 23, 2007, 10:03:26 PM »
Nice. No, I didn't know that was available. Thanks.

Offline Mr Blah Man

  • Semi-Newbie
  • *
  • Posts: 41
Re: Hiding a theme
« Reply #14 on: November 24, 2007, 06:46:46 PM »
I only know Java but even I know you can just make it:

Code: [Select]
$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.
« Last Edit: November 24, 2007, 07:29:12 PM by Mr Blah Man »

bloc

  • Guest
Re: Hiding a theme
« Reply #15 on: November 25, 2007, 07:02:58 AM »
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")