Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-04-2016, 02:03 AM
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Location: USA
Posts: 647
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default injecting into admincp settings?

im trying to include a stylesheet in my settings page, i managed to get it to load in but not in a good way. It adds the code to the very end of the page.

Code:
</body>
</html><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">
the plugin I created:
Code:
<plugin active="1" executionorder="1" product="vbulletin">
      <title>font awesome in settings</title>
      <hookname>admin_complete</hookname>
      <phpcode><![CDATA[if ($vbulletin->options['drc_fa_adm']){
   echo('<link rel="stylesheet" href="'.$vbulletin->options['drc_fa_prov'].'">');
}]]></phpcode>
	</plugin>



even though this works, I would like to know... is there anyway i can properly inject stylesheets and/or scripts into the settings page?
Reply With Quote
  #2  
Old 05-05-2016, 02:49 PM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here install this mod and then create a setting where the option code is:
Code:
css:my_custom_css_file.css
Replace the red part with the path to your custom css file. Other than the variable name, the only other value that matters when creating the setting is the title.
Attached Files
File Type: xml product-squid_css_admin_option.xml (950 Bytes, 3 views)
Reply With Quote
Благодарность от:
Dr.CustUmz
  #3  
Old 05-05-2016, 03:42 PM
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Location: USA
Posts: 647
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks squid, this is the hook I ended up using already =) but that hook, some option pages like turn site on off don't have that hook, and one of my products (didnt check every default settings page) actually has that hook 2ce so the stylesheet loads 2ce.

I tried using some js in the admin complete hook
Code:
$drcjQ = "<link ref=\"stylesheet\" href=\"style.css\">";

echo "<script>var headHTML = document.getElementsByTagName('head')[0].innerHTML;
headHTML    += '" . $drcjQ . "';
document.getElementsByTagName('head')[0].innerHTML = headHTML;</script>";
and even though it adds it to the head, it doesnt work =/

side note* I am out of iframes when im testing this, i open the options in a new tab and go to the settings of the product I'm working on.
example: yoursite.com/admincp/options.php?do=options&dogroup=onoff

so its the full page and no nav on the left or bar at the top

--------------- Added [DATE]1462470531[/DATE] at [TIME]1462470531[/TIME] ---------------

this is what I have currently working btw I'd just like to be able to get it working in the HEAD
Code:
<hookname>admin_options_print</hookname>
<phpcode><![CDATA[if ($vbulletin->options['drc_fa_adm']){
  echo '<link rel="stylesheet" href="'.$vbulletin->options['drc_fa_prov'].'">';
}]]></phpcode>
Reply With Quote
  #4  
Old 05-05-2016, 04:27 PM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dr.CustUmz View Post
thanks squid, this is the hook I ended up using already =) but that hook, some option pages like turn site on off don't have that hook, and one of my products (didnt check every default settings page) actually has that hook 2ce so the stylesheet loads 2ce.

I tried using some js in the admin complete hook
Code:
$drcjQ = "<link ref=\"stylesheet\" href=\"style.css\">";

echo "<script>var headHTML = document.getElementsByTagName('head')[0].innerHTML;
headHTML    += '" . $drcjQ . "';
document.getElementsByTagName('head')[0].innerHTML = headHTML;</script>";
and even though it adds it to the head, it doesnt work =/

side note* I am out of iframes when im testing this, i open the options in a new tab and go to the settings of the product I'm working on.
example: yoursite.com/admincp/options.php?do=options&dogroup=onoff

so its the full page and no nav on the left or bar at the top

--------------- Added [DATE]1462470531[/DATE] at [TIME]1462470531[/TIME] ---------------

this is what I have currently working btw I'd just like to be able to get it working in the HEAD
Code:
<hookname>admin_options_print</hookname>
<phpcode><![CDATA[if ($vbulletin->options['drc_fa_adm']){
  echo '<link rel="stylesheet" href="'.$vbulletin->options['drc_fa_prov'].'">';
}]]></phpcode>
I think your misunderstanding how to use the product. On your product page (i.e. yoursite.com/admincp/options.php?do=options&dogroup=my_product_page) add a new setting with option code:
Code:
css:style.css
As long as you don't define multiple css settings for a particular option page you won't have multiple instances of the css being loaded.

For any settings page that you want custom css to be applied to, add a new settings with css:... as the option code.

EDIT: To clarify, this will only add your custom css to those settings pages where you add a setting that has the specified option code. The product will not add it to all settings group pages.
Reply With Quote
  #5  
Old 05-05-2016, 04:40 PM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's what I mean, the first image is a new setting I create within any settings group.


Here's viewing the actual settings page. The style.css file has a single entry .alt1{background-color:red;}

Attached Images
File Type: jpg new css setting.jpg (46.3 KB, 0 views)
File Type: jpg settings with custom css.jpg (23.9 KB, 0 views)
Reply With Quote
  #6  
Old 05-05-2016, 05:56 PM
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Location: USA
Posts: 647
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thats actually pretty cool, but it's not what im going for. Im going to have a core product that must be installed for my addons, and in that product is where i apply the style sheet for its (and all my other products) settings. That way i can use jquery and stylesheets and theyre all loaded from the core product, so in a new products settings i can just call the classes and what not.

its hard to explain not having released it yet, but i hope you get it =/

--------------- Added [DATE]1462489633[/DATE] at [TIME]1462489633[/TIME] ---------------

i tried this @admin_options_print just to test

Code:
$alreadyLoaded = array('one' => false, 'two' => false);
if (!$alreadyLoaded['one']) {
  echo 'ECHO';
  $alreadyLoaded['one'] = true;
}
and it still echo's twice... now I have lost all faith in humanity lol.

whats going on =/

this is my settings page
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04466 seconds
  • Memory Usage 2,249KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (9)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (1)post_thanks_box_bit
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (3)postbit_attachment
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete