vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.7 Template Modifications (https://vborg.vbsupport.ru/forumdisplay.php?f=229)
-   -   Forum Display Enhancements - Hide a style from style chooser (https://vborg.vbsupport.ru/showthread.php?t=183185)

dartho 06-21-2008 10:00 PM

Hide a style from style chooser
 
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 my mobile style, you will not need to do this as it is (soon will be) an option as of version 0.0.3.

See this post 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 ****
Quote:

Originally Posted by dartho
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:
Code:

<option value="$optionvalue" class="$optionclass" $optionselected>$optiontitle</option>
and change it to the following:
Code:

<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:

Code:

<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 06-22-2008 12:23 AM

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 06-22-2008 02:19 AM

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 06-22-2008 05:58 AM

Quote:

Originally Posted by dartho (Post 1555780)
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 06-22-2008 07:18 AM

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 06-22-2008 02:58 PM

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 06-22-2008 09:20 PM

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 06-23-2008 10:41 AM

Quote:

Originally Posted by dartho (Post 1555874)
...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 06-24-2008 01:40 AM

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 06-24-2008 06:51 AM

Updated! Installs as a plugin with no template edits and no resource usage concerns as in post #6 and #7.

BeerLuver 06-24-2008 06:25 PM

Thanks for the update dartho :)

mesdar 07-15-2008 03:06 PM

thanx

sung 12-04-2008 11:31 PM

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-12-2008 07:45 PM

Quote:

Originally Posted by sung (Post 1678738)
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 12-31-2008 04:06 AM

I've installed this and put in ID in the edit but it still shows in the dropdown.

https://vborg.vbsupport.ru/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://vborg.vbsupport.ru/external/2008/12/6.jpg

Merriweather 03-07-2009 05:14 AM

Is there a way to hide more than one skin with this mod?

dartho 03-09-2009 05:00 AM

This is probably not very efficient, but you could edit the plugin and duplicate the code for each styleid...

PHP Code:

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 06-24-2009 07:13 PM

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 07-05-2009 07:44 PM

works great on 3.8.3 :)

choccyclaire 12-10-2009 02:50 AM

Quote:

Originally Posted by sung (Post 1684074)
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.


All times are GMT. The time now is 09:29 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01222 seconds
  • Memory Usage 1,791KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (20)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete