vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Template Css adding in my addon (https://vborg.vbsupport.ru/showthread.php?t=269059)

Asterix_ita 08-24-2011 10:51 AM

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

Lynne 08-24-2011 03:11 PM

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


Asterix_ita 08-24-2011 03:22 PM

Thanks Lynne

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

Regards

Lynne 08-24-2011 03:29 PM

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';


Asterix_ita 08-24-2011 03:46 PM

1 Attachment(s)
Thanks it works fine.

You know how these two ways of interpreting the CSS code

Regards

Lynne 08-24-2011 07:50 PM

I have no idea why that gap is there. You'd need to analyze the box using something like firebug.

CvP 11-25-2011 04:52 PM

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';
    } 


Asterix_ita 11-25-2011 05:22 PM

Hi CvP

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

regards

CvP 11-25-2011 11:15 PM

Yes, it needs to be on parse_templates. I used process_templates_complete and banging my head on table until Lynne stepped in.

Boofo 11-26-2011 12:31 AM

Quote:

Originally Posted by Lynne (Post 2237486)
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?


All times are GMT. The time now is 08:12 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.01116 seconds
  • Memory Usage 1,748KB
  • 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
  • (1)bbcode_html_printable
  • (2)bbcode_php_printable
  • (1)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