PDA

View Full Version : Forum Display Enhancements - Hide a style from style chooser


dartho
21 Jun 2008, 23:18
A simple plugin which will allow you to hide a specified user selectable style from the Quick Style Chooser which appears at the bottom of every page in vBulletin whilst still allowing the style to be used.

Instructions:
0. If you made modifications to your 'options' template as per previous instructions, you will need to revert the template
1. Import attached plugin via "Products and Plugins"," Download/Upload Plugin"
2. Go into the plugin manager and edit the "Hide Style From Style Chooser" plugin
3. Change the 'x' in '$mo37_hidden_styleid = x' to be the StyleID of the style you wish to hide
4. Set the plugin status to be active
5. Save
The style is now hidden, but still usable by you users.

To disable/uninstall, set the plugin status to not be active or delete the plugin.

If you use the add-on that extends (http://www.vbulletin.org/forum/showthread.php?t=182692) my mobile style (http://www.vbulletin.org/forum/showthread.php?t=174375), you will not need to do this as it is (soon will be) an option as of version 0.0.3.

See this post (http://www.vbulletin.org/forum/showpost.php?p=1684074&postcount=14) for a plugin which hides the chooser in usercp options.


All posts in this thread up to post #9 were in reference to the original way I thought of doing this. I have kept the original contents of this template modification below for reference




**** FOLLOWING INFORMATION KEPT FOR REFERENCE ONLY ****

If you have multiple styles installed but wish to 'hide' some from users while still be able to use them you can use this template modification to hide particular styles form the quick chooser:

Edit your 'options' template - the original should look like this:
<option value="$optionvalue" class="$optionclass" $optionselected>$optiontitle</option>


and change it to the following:

<if condition="($optionvalue!=x) && ($optiontitle!='yyyyyy')">
<option value="$optionvalue" class="$optionclass" $optionselected>$optiontitle</option>
</if>

where x is the styleid of your mobile style and yyyyyy is the name of your mobile style. The name is case sensative!

This should stop it being added to the drop down list.

If you wish to hide multiple styles , you could extend the conditional as follows:


<if condition="(($optionvalue!=x1) && ($optiontitle!='yyyyyy1')) || (($optionvalue!=x2) && ($optiontitle!='yyyyyy2'))">
<option value="$optionvalue" class="$optionclass" $optionselected>$optiontitle</option>
</if>

where x2 is the 2nd styleid and yyyyyy2 is the 2nd style name.

ssslippy
22 Jun 2008, 01:23
If u uncheck the box on the left when view the styles it will prevent users from using that one. Its part of the default.

dartho
22 Jun 2008, 03:19
That is true - but there are instances where you want the style available to a user, but you do not wish them to be able to select it. An example is my mobile detection hack. The style must be user selectable for this to work, but you don;t want PC users to select it. Or if you are developing a style on your site and you want a standard user/guest to be able to use it for testing, but don't want it showing up in the style selector..

whitetigergrowl
22 Jun 2008, 06:58
That is true - but there are instances where you want the style available to a user, but you do not wish them to be able to select it. An example is my mobile detection hack. The style must be user selectable for this to work, but you don;t want PC users to select it. Or if you are developing a style on your site and you want a standard user/guest to be able to use it for testing, but don't want it showing up in the style selector..


Ummm if the box is unchecked and saved, you do realize members still cannot choose it because its hidden....right?!

dartho
22 Jun 2008, 08:18
Yes that is correct. That is why you would make the style user selectable (by checking the box and saving) , but hide it with a template edit such as this. I could then give the user a link, or use rewrites in my htaccess, or write a plugin that selects the style.

Why are people posting to this thread when they seem to have no need for it?

I only released it here as it is something I use and find personally useful and thought others may feel the same.

Let me give you a real life scenario which may help you understand where this has a purpose, and indeed why I wrote it.


My site has 2 styles which users can choose.
My site also has a mobile friendly style.
A plugin detects if a mobile device has connected to my site and then changes the style to the mobile style automatically
For a plugin (or anything for that matter) to be able to change the style for a non-admin user, the style must be user selectable
I don't want desktop PC users to be able to select the mobile friendly style as it looks crap on a desktop PC


Solution?
Hide the styles which I don't want PC users to manually select whilst allowing the system to still assign them.

Thus this template edit.

waza
22 Jun 2008, 15:58
The 'option' template is used almost everywhere a select box appears, so not only for the templates.
This leads on a big system that your server will do a huge amount of if(condition) calculations that are not necessary.

dartho
22 Jun 2008, 22:20
That is true. I've not noticed any performance degradation on my site, that's not to say there won't be any and admins should of course monitor as they would after making any modifications.

I appreciate this type of feedback and I am looking for a more eloquent solution but in the mean time it's this or nothing for me.

Darat
23 Jun 2008, 11:41
...snip...
[/LIST]

Solution?
Hide the styles which I don't want PC users to manually select whilst allowing the system to still assign them.

Thus this template edit.

Thanks - it's a useful little snippet to have.

BeerLuver
24 Jun 2008, 02:40
Thanks dartho. Useful for hiding the default style; but still being able to use it as a basic template to make a new style within the admin panel. As opposed to deleting it outright.

dartho
24 Jun 2008, 07:51
Updated! Installs as a plugin with no template edits and no resource usage concerns as in post #6 and #7.

BeerLuver
24 Jun 2008, 19:25
Thanks for the update dartho :)

mesdar
15 Jul 2008, 16:06
thanx

sung
05 Dec 2008, 00:31
Is there anyway so that the style is also hidden from the Forum Skin drop down list in the User CP and not just the Quick Style Chooser?

sung
12 Dec 2008, 20:45
Is there anyway so that the style is also hidden from the Forum Skin drop down list in the User CP and not just the Quick Style Chooser?

Made a plugin that does just this. It uses the same variable ($mo37_hidden_styleid) to hide the style, and is inactive by default.

So assuming you're already using dartho's plugin and it is working just upload this one and set it active and the same style will be hidden in the User CP as well.

fta2k
31 Dec 2008, 05:06
I've installed this and put in ID in the edit but it still shows in the dropdown.

https://www.vbulletin.org/forum/external/2008/12/5.jpg

Any ideas?


EDIT:

Ok, I'm an idiot.

I was using skin display number and not skin id. It's all fixed now.

https://www.vbulletin.org/forum/external/2008/12/6.jpg

Merriweather
07 Mar 2009, 06:14
Is there a way to hide more than one skin with this mod?

dartho
09 Mar 2009, 06:00
This is probably not very efficient, but you could edit the plugin and duplicate the code for each styleid...


mo37_hidden_styleid = x;
$mo37start = strpos($quickchooserbits, '<option value="'.$mo37_hidden_styleid.'"');
if ($mo37start !== FALSE) {
$quickchooserbits = substr($quickchooserbits , 0, $mo37start).substr($quickchooserbits , strpos($quickchooserbits, '</option>', $mo37start) + strlen('</option>'));
}
mo37_hidden_styleid = y;
$mo37start = strpos($quickchooserbits, '<option value="'.$mo37_hidden_styleid.'"');
if ($mo37start !== FALSE) {
$quickchooserbits = substr($quickchooserbits , 0, $mo37start).substr($quickchooserbits , strpos($quickchooserbits, '</option>', $mo37start) + strlen('</option>'));
}


replace 'x' with one styleid, and 'y' with the next ...

burntire
24 Jun 2009, 20:13
I just went to -vb options-Style & Language Settings- and unchecked the ability to change styles. In the 2 styles I use I allow user selection. This removes the ability to change styles from the footer and usercp, but it also forces the mobile style with the mobile detection mod.

accludetuner
05 Jul 2009, 20:44
works great on 3.8.3 :)

choccyclaire
10 Dec 2009, 03:50
Made a plugin that does just this. It uses the same variable ($mo37_hidden_styleid) to hide the style, and is inactive by default.

So assuming you're already using dartho's plugin and it is working just upload this one and set it active and the same style will be hidden in the User CP as well.

What about if you used darthos example a few posts above in order to hide more than one?

When I used this plugin it just eliminated the last style.