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.


All times are GMT. The time now is 03:09 AM.

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.01000 seconds
  • Memory Usage 1,749KB
  • 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
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete