vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   injecting into admincp settings? (https://vborg.vbsupport.ru/showthread.php?t=322522)

Dr.CustUmz 05-04-2016 02:03 AM

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>

https://vborg.vbsupport.ru/external/2016/05/28.png


even though this works, I would like to know... is there anyway i can properly inject stylesheets and/or scripts into the settings page?

squidsk 05-05-2016 02:49 PM

1 Attachment(s)
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.

Dr.CustUmz 05-05-2016 03:42 PM

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>


squidsk 05-05-2016 04:27 PM

Quote:

Originally Posted by Dr.CustUmz (Post 2570212)
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.

squidsk 05-05-2016 04:40 PM

1 Attachment(s)
Here's what I mean, the first image is a new setting I create within any settings group.
https://vborg.vbsupport.ru/attachmen...1&d=1462473526

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

https://vborg.vbsupport.ru/attachmen...1&d=1462473614

Dr.CustUmz 05-05-2016 05:56 PM

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
https://vborg.vbsupport.ru/external/2016/05/27.png


All times are GMT. The time now is 10:06 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.01010 seconds
  • Memory Usage 1,737KB
  • 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
  • (9)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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