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?

HMBeaty 11-26-2011 01:40 AM

Quote:

Originally Posted by Boofo (Post 2271973)
What hooks would you use if the css IS stored in the file system?

custom_css_links

HMBeaty 12-08-2011 03:40 AM

Changing this up a bit....in the headinclude template here:
HTML Code:

    <!--[if lt IE 8]>
    {vb:cssfile popupmenu-ie.css,vbulletin-ie.css,vbulletin-chrome-ie.css,vbulletin-formcontrols-ie.css,editor-ie.css}
    <![endif]-->

{vb:raw template_hook.headinclude_css}

Would it be safe to say we can use the template hook headinclude_css to add on to the -ie.css? For example, I'd like to add sidebar-ie.css to it, but unsure if that would work (since I don't use IE 8).

Also, if we can use that hook location, would we use the same method of adding to the store css as files? Like this maybe? .....
HTML Code:

$template_hook['headinclude_css'] .= '<link type="text/css" rel="stylesheet" href="' . vB_Template::fetch_css_path() . 'sidebar-ie.css' . '?d=' . $style['dateline'] . '" />';
Or would it just be....
HTML Code:

$template_hook['headinclude_css'] .= 'sidebar-ie.css';
Thanks in advance :D

Lynne 12-08-2011 04:08 PM

If you want to add something for IE only, you need to put that comment code around it.

HMBeaty 12-09-2011 01:15 AM

So something like this should work, right?
PHP Code:

$template_hook['headinclude_css'] .= '<!--[if lt IE 8]>{vb:cssfile MY_CSS.css}<![endif]-->'

Sorry, haven't been able to think straight the past few days :(

HMBeaty 12-10-2011 03:16 AM

This appears to work (not sure if it's correct though) .....
PHP Code:

$template_hook['headinclude_css'] .= '<!--[if lt IE 8]>
<script type="text/javascript" src="clientscript/vbulletin-threadlist-ie.js?v={vb:raw vboptions.simpleversion}"></script>
<link type="text/css" rel="stylesheet" href="' 
vB_Template::fetch_css_path() . 'sidebar-ie.css' '?d=' $style['dateline'] . '" />
<![endif]-->'



Boofo 01-17-2012 08:14 AM

Not to beat a dead horse, but how come the css files don't need to be rendered before you add them to the hooks?

Lynne 01-17-2012 11:05 PM

Because they are special and dealt with in a different way?

Boofo 01-17-2012 11:24 PM

Are you guessing? ;)

How's this for posterity, young lady?

Quote:

// 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. The custom_css_links hook requires a full on link.
// Also, this needs to be on the parse_templates hook, not on process_templates_complete. -- Lynne

That is in my first mod using the css hooks. I'll make you famous. ;)

Lynne 01-18-2012 06:40 PM

Wonderful. Do I get the fortune that comes with being famous?

Boofo 01-18-2012 07:03 PM

Whatever you want. You know I'm a sucker for your charms. ;)


All times are GMT. The time now is 07:18 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.01119 seconds
  • Memory Usage 1,773KB
  • 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
  • (4)bbcode_html_printable
  • (4)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (20)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