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

Reply
 
Thread Tools Display Modes
  #1  
Old 01-02-2013, 12:33 AM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default css not showing up when css saved as file

What code do I need to add/modify to get my css template to show up when the setting save css stylesheets as file to true? The css in the template show up when the setting is false.

I'm guessing its a relatively simple change/addition but I'm not spotting it.

EDIT: This is getting css for elements added to the postbit, not for a custom page
Reply With Quote
  #2  
Old 01-02-2013, 01:51 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not sure how you're adding your CSS template now, but if you use the function vB_Template::fetch_css_path() to build the url, it should work either way. For instance you could use $template_hook['headinclude_css'] like:

Code:
$template_hook['headinclude_css'] .= '<link rel="stylesheet" type="text/css" href="' . vB_Template::fetch_css_path() . 'my_css.css?d=' . $style['dateline'] . '" />';

or if you're putting it in a template you could just use {vb:cssfile my_css.css} .
Reply With Quote
  #3  
Old 01-02-2013, 03:31 AM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
I'm not sure how you're adding your CSS template now, but if you use the function vB_Template::fetch_css_path() to build the url, it should work either way. For instance you could use $template_hook['headinclude_css'] like:

Code:
$template_hook['headinclude_css'] .= '<link rel="stylesheet" type="text/css" href="' . vB_Template::fetch_css_path() . 'my_css.css?d=' . $style['dateline'] . '" />';

or if you're putting it in a template you could just use {vb:cssfile my_css.css} .
Currently the template is referred to in two plugins:

The first plugin is at the cache_templates with the following code:

Code:
if(THIS_SCRIPT=='css')
{
   $cache[] = 'my_css.css';
}
The second is at the css_start hook with the following code:

Code:
if(in_array('vbulletin.css',$matches[1]))
{
   $matches[1][] = 'my_css.css';
}
As a note I've inherited this code so I'm not sure which of these, if either, is responsible for including the css when css is not stored as a file.
Reply With Quote
  #4  
Old 01-02-2013, 12:01 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by squidsk View Post
As a note I've inherited this code so I'm not sure which of these, if either, is responsible for including the css when css is not stored as a file.
That first plugin just caches your template, and the second one includes your css template when css.php is called (when CSS is not stored as a file). So unless there's more code somewhere else, it doesn't look like anything was done to include it when CSS is stored as a file. What you can do is create a new plugin using hook parse_templates and code like this:

Code:
if ($vbulletin->options['storecssasfile'])
{
    $template_hook['headinclude_css'] .= '<link rel="stylesheet" type="text/css" href="' . vB_Template::fetch_css_path() . 'my_css.css" />';
}

But there's one issue - this will load my_css.css on every page. If you can list the pages that actually need it, then you could limit it to those pages by also doing a check of THIS_SCRIPT.
Reply With Quote
  #5  
Old 01-02-2013, 12:28 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There's another way to do it: create a cssrollup xml file and put it in includes/xml. For exaample you could name it cssrollup_myproduct.xml and have contents like this:

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<css product="my_product_id">
	<rollup name="main-rollup.css">
		<template>mycss.css</template>
	</rollup>
</css>

Then rebuild the styles (under Maintenance > General update tools). Then you don't need any extra code or plugins.

Edit: There are other rollups than 'main', so if you're really concerned about efficiency, you could determined which one you need. There is one called 'postbit' so maybe that would work for you.
Reply With Quote
Благодарность от:
squidsk
  #6  
Old 01-03-2013, 01:40 PM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
There's another way to do it: create a cssrollup xml file and put it in includes/xml. For exaample you could name it cssrollup_myproduct.xml and have contents like this:

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<css product="my_product_id">
	<rollup name="main-rollup.css">
		<template>mycss.css</template>
	</rollup>
</css>

Then rebuild the styles (under Maintenance > General update tools). Then you don't need any extra code or plugins.

Edit: There are other rollups than 'main', so if you're really concerned about efficiency, you could determined which one you need. There is one called 'postbit' so maybe that would work for you.
Worked like a charm thanks! The only problem is that there aren't roll-ups for all the pages I need them for so I ended up having to put it into main-rollup.css, but its a small amount of css so I'm not too worried.
Reply With Quote
  #7  
Old 01-03-2013, 03:14 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by squidsk View Post
The only problem is that there aren't roll-ups for all the pages I need them for so I ended up having to put it into main-rollup.css, but its a small amount of css so I'm not too worried.

I agree, I think it's OK. Also, now that I see you're working on your product - I don't think you would need to rebuild the styles manually if the file is uploaded before the product is imported, so you shouldn't need any special instructions or anything.
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 10:01 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.07711 seconds
  • Memory Usage 2,234KB
  • Queries Executed 11 (?)
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
  • (7)bbcode_code
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (1)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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_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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete