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 08-24-2011, 10:51 AM
Asterix_ita's Avatar
Asterix_ita Asterix_ita is offline
 
Join Date: Aug 2009
Location: Italy
Posts: 312
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Template Css adding in my addon

I used this plugin to upload my template.css, but sometimes is it loaded and others no why? (vBulletin 4.1.5)

Code:
		
<plugin active="1" executionorder="5">
<title>CSS</title>
<hookname>parse_templates</hookname>
<phpcode><![CDATA[
			if($vbulletin->options['ct_list_active'])
				{
					$template_hook['custom_css_list'] .= ',ct_thread.css';
				}
]]></phpcode>
</plugin>
Is there any other way to load your css template?

In several articles I found this code, but everyone says outdated

Code:
		<plugin active="1" executionorder="5">
			<title>CSS - Inject CSS into vBulletin</title>
			<hookname>css_start</hookname>
			<phpcode><![CDATA[if(in_array('vbulletin.css',$matches[1]))
{
   $matches[1][] = 'ct_thread.css';
}]]></phpcode>
		</plugin>
Thanks

Regards
Reply With Quote
  #2  
Old 08-24-2011, 03:11 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Take a look at the headinclude template:
HTML Code:
<vb:if condition="$vboptions['storecssasfile']">
    {vb:cssfile main-rollup.css}
        {vb:raw template_hook.custom_css_links}
<vb:else />
    {vb:cssfile bbcode.css,editor.css,popupmenu.css,reset-fonts.css,vbulletin.css,vbulletin-chrome.css,vbulletin-formcontrols.css{vb:raw template_hook.custom_css_list}}
</vb:if>
There is an if/else there. You can only use the template hook custom_css_list if the css is not being stored in the file system. So, two different template_hooks need to be defined.

PHP Code:
$template_hook['custom_css_links'] .= xxxxxx;
$template_hook['custom_css_list'] .= yyyyyy
Reply With Quote
  #3  
Old 08-24-2011, 03:22 PM
Asterix_ita's Avatar
Asterix_ita Asterix_ita is offline
 
Join Date: Aug 2009
Location: Italy
Posts: 312
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Lynne

I have to replace xxxx and yyy with the name of my template.css, is it correct?

Regards
Reply With Quote
  #4  
Old 08-24-2011, 03:29 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, not exactly. The _links hook requires a full on link. (I actually got this code from one of BOPs mods.)

Try this:
Code:
$template_hook['custom_css_links'] .= '<link rel="stylesheet" type="text/css" href="clientscript/vbulletin_css/style' . str_pad($style['styleid'], 5, '0', STR_PAD_LEFT) . $vbulletin->stylevars['textdirection']['string'][0] . '/ct_thread.css" />';

$template_hook['custom_css_list'] .= ',ct_thread.css';
Reply With Quote
Благодарность от:
CvP
  #5  
Old 08-24-2011, 03:46 PM
Asterix_ita's Avatar
Asterix_ita Asterix_ita is offline
 
Join Date: Aug 2009
Location: Italy
Posts: 312
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks it works fine.

You know how these two ways of interpreting the CSS code

Regards
Attached Images
File Type: jpg Selezione_128.jpg (23.0 KB, 0 views)
File Type: jpg Selezione_129.jpg (24.3 KB, 0 views)
Reply With Quote
  #6  
Old 08-24-2011, 07:50 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have no idea why that gap is there. You'd need to analyze the box using something like firebug.
Reply With Quote
  #7  
Old 11-25-2011, 04:52 PM
CvP's Avatar
CvP CvP is offline
 
Join Date: Aug 2006
Posts: 263
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I actually got in to some trouble with this a few minutes ago and Lynne was kind enough (as always!) to point me I'm using process_tempaltes_complete instead of parse_templates.

With that help, now I am using this in my codes:

PHP Code:
    if ($vbulletin->options['storecssasfile']) {
        
$template_hook['custom_css_links'] .= '<link type="text/css" rel="stylesheet" href="' vB_Template::fetch_css_path() . 'MY_CSS.css' '?d=' $style['dateline'] . '" />';
    }
    else {
        
$template_hook['custom_css_list'] .= 'MY_CSS.css';
    } 
Reply With Quote
3 благодарности(ей) от:
Asterix_ita, HMBeaty, Lynne
  #8  
Old 11-25-2011, 05:22 PM
Asterix_ita's Avatar
Asterix_ita Asterix_ita is offline
 
Join Date: Aug 2009
Location: Italy
Posts: 312
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi CvP

Thanks, but your code works fine on my addon with parse_templates hook, doesn't work with process_tempaltes_complete

regards
Reply With Quote
  #9  
Old 11-25-2011, 11:15 PM
CvP's Avatar
CvP CvP is offline
 
Join Date: Aug 2006
Posts: 263
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, it needs to be on parse_templates. I used process_templates_complete and banging my head on table until Lynne stepped in.
Reply With Quote
  #10  
Old 11-26-2011, 12:31 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
You can only use the template hook custom_css_list if the css is not being stored in the file system. So, two different template_hooks need to be defined.
What hooks would you use if the css IS stored in the file system?
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 06:04 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.04711 seconds
  • Memory Usage 2,296KB
  • 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
  • (3)bbcode_code
  • (1)bbcode_html
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (4)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (2)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete