Simple Machines Community Forum

Customizing SMF => Graphics and Templates => Thema gestartet von: 1MileCrash in August 02, 2005, 01:45:05 NACHMITTAGS

Titel: preventing use of a certain theme
Beitrag von: 1MileCrash in August 02, 2005, 01:45:05 NACHMITTAGS
what would i need to do to prevent anyone from using a certain theme? I searched and got nadda.
Titel: Re: preventing use of a certain theme
Beitrag von: Kindred in August 02, 2005, 01:53:19 NACHMITTAGS
ummm.... delete the theme?
Titel: Re: preventing use of a certain theme
Beitrag von: 1MileCrash in August 02, 2005, 02:10:43 NACHMITTAGS
no, i need to have it. I dont want to explain right now, but i must have the theme.
Titel: Re: preventing use of a certain theme
Beitrag von: Kindred in August 02, 2005, 02:28:37 NACHMITTAGS
then either turn off the option for users to change their theme....   or write a mod...
Titel: Re: preventing use of a certain theme
Beitrag von: 1MileCrash in August 02, 2005, 02:37:12 NACHMITTAGS
i have already thought over the obvious answers....and i dont see the point of writing a mod, considering i dont want to make any new feature, or functionallity, and not many people will find use to this request. I just want to disable the option of the theme to show up, but it still needs to be installed.
Titel: Re: preventing use of a certain theme
Beitrag von: Kindred in August 02, 2005, 02:43:32 NACHMITTAGS
Tippmaster...   what you are looking to do is add a function that does not currently exist.   Hence a mod.
Titel: Re: preventing use of a certain theme
Beitrag von: 1MileCrash in August 02, 2005, 02:46:43 NACHMITTAGS
i was thinking something more along the lines of a "Tips and Tricks" thing. Like a simple line of code that would prevent the id of the theme from being displayed under "Looks and layout preferences".

I could go without doing this, i would just have to install two forums.
Titel: Re: preventing use of a certain theme
Beitrag von: bloc in August 02, 2005, 03:43:14 NACHMITTAGS
There is one possibility...

If you open up Themes.template.php in default theme folder(and also any other theme that has that template) and find this code:
// 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 />';
}


And simply insert an IF statement there, to check the id..you could do what you need. It would be just the option of choosing of course..doing index.php?theme=xx would still work as before.
// This template allows for the selection of different themes ;).
function template_pick()
{
        global $context, $settings, $options, $scripturl, $txt;

        $hidden_themeID= 5;

        // 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 />';
        }
}

Titel: Re: preventing use of a certain theme
Beitrag von: 1MileCrash in August 02, 2005, 03:44:25 NACHMITTAGS
Thanks bloc! That's exactly the kind of thing i was hoping to get!  :D


EDIT: do any current themes have their own Themes.template.php? Or no?
Titel: Re: preventing use of a certain theme
Beitrag von: bloc in August 02, 2005, 03:53:32 NACHMITTAGS
Oh, yes. ;) My themes. :P

Well, at least Themis, Helios, Simplicity etc. But none of them have changed that function, so you could copy the entire bit over in one sweep on each.

EDIT:

Of course this could be done at source file level too, but when upgrading the forum its lost. In themes it won't be, except for default theme.
Titel: Re: preventing use of a certain theme
Beitrag von: 1MileCrash in August 02, 2005, 04:00:21 NACHMITTAGS
im here to conclude that this worked flawlessly. Whatever theme i specify, it remains hidden.

Im just going to edit all of your theme's Themes.template.php as well. You themes are worth it.  :D
Titel: Re: preventing use of a certain theme
Beitrag von: bloc in August 02, 2005, 05:15:43 NACHMITTAGS
:) Good to hear it worked fine.
Titel: Re: preventing use of a certain theme
Beitrag von: [Unknown] in August 02, 2005, 09:11:48 NACHMITTAGS
Actually, the simplest way is to edit the "knownThemes" row in the settings table, and remove the theme's id from the list.

Only administrators will be able to use the theme (and only with direct links containing ?theme=###) after that, until the id is put back in the list.

-[Unknown]
Titel: Re: preventing use of a certain theme
Beitrag von: 1MileCrash in August 02, 2005, 10:56:18 NACHMITTAGS
ill have to try that [Unknown]

Bloc, there actually is a problem with the code you posted. I cannot switch themes. All but the hidden ones display, but the links do nothing, it just refreshes the page...and keeps me on the same skin.. :(
Titel: Re: preventing use of a certain theme
Beitrag von: bloc in August 03, 2005, 06:51:04 VORMITTAG
There shouldn't be any different with that code...have you tried to use a theme with the original code intact? Just to check if it really is the changed code?
Titel: Re: preventing use of a certain theme
Beitrag von: bloc in August 03, 2005, 06:52:21 VORMITTAG
Zitat von: [Unknown] in August 02, 2005, 09:11:48 NACHMITTAGS
Actually, the simplest way is to edit the "knownThemes" row in the settings table, and remove the theme's id from the list.

Only administrators will be able to use the theme (and only with direct links containing ?theme=###) after that, until the id is put back in the list.

-[Unknown]

A much simpler solution, yes. ;D And it will affect all themes right away too.
Titel: Re: preventing use of a certain theme
Beitrag von: 1MileCrash in Januar 14, 2006, 01:02:45 NACHMITTAGS
sorry for the bumpage...

regarding [unknown]'s suggestion, if i delete it from the knownThemes row, will i still be able to use the theme in SSI? like $ssi_theme = 4; or w/e it is.

Zitat von: [Unknown] in August 02, 2005, 09:11:48 NACHMITTAGS
Actually, the simplest way is to edit the "knownThemes" row in the settings table, and remove the theme's id from the list.

Only administrators will be able to use the theme (and only with direct links containing ?theme=###) after that, until the id is put back in the list.

-[Unknown]
Titel: Re: preventing use of a certain theme
Beitrag von: kat in November 12, 2006, 02:53:18 NACHMITTAGS
When I'm fiddling with a theme, I just post a message telling everyone that I'm working on it, reset everyone to the forum default theme and uncheck "Allow users to change their themes" in admin, until I'm done. ;)