Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
[HOW TO - VB4] Adding Stylesheets to Your vB4 Mod via Plugins
CarlitoBrigante's Avatar
CarlitoBrigante
Join Date: Nov 2002
Posts: 182

 

Iceland
Show Printable Version Email this Page Subscription
CarlitoBrigante CarlitoBrigante is offline 11-24-2009, 10:00 PM

THIS ARTICLE IS NO LONGER NEEDED FOR vB 4.0.0+: you can now just use the hook in the headinclude_bottom template: headinclude_bottom_css. As I wrote at the beginning of this tutorial, this was to help people working with beta versions.

As many coders have noticed, we still don't have a template hook in headinclude to add our own CSS to the css.php call in the template. Additionally, the simple method I am listing here might still be useful in the future, even when we get that hook.

One of the great things of the new vBulletin, in fact, is that you can manipulate CSS generation as you have been used to in your scripts.

Here you go.

1. First, add a template in Style & Templates, and assign it to your product in development. Let's call this template yourproduct.css.
2. Now, add a plugin for your product for caching this template. Go to Plugin Manager -> Add Plugin, call the plugin as you prefer, then choose the cache_template hook, and finally put the following code in it:
Code:
if(THIS_SCRIPT=='css')
{
   $cache[] = 'yourproduct.css';
}
3. Add another plugin for your product. Choose the css_start hook, then place this code in it:
Code:
if(in_array('vbulletin.css',$matches[1]))
{
   $matches[1][] = 'yourproduct.css';
}
The in_array check makes sure that your CSS is added only to the main vbulletin.css call.

That's it - your CSS will be added to the generated CSS file.
Reply With Quote
  #12  
Old 01-22-2010, 06:56 PM
xman_79's Avatar
xman_79 xman_79 is offline
 
Join Date: Jun 2006
Location: Romania
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I had a similar problem , and :

In my php file i add :

PHP Code:
$myvbcsspath 'css.php?styleid=' $style['styleid'] . '&langid=' LANGUAGEID '&d=' $style['dateline'] . '&td=' $vbulletin->stylevars['textdirection']['string'] . '&sheet='

PHP Code:
$templater->register('myvbcsspath'$myvbcsspath); 
And in my template :
HTML Code:
<link rel="stylesheet" type="text/css" href="{vb:raw myvbcsspath}mytemplate.css" />
*Rebuild style information .

Now it's work .

Look includes/class_core.php , Line 3994
Reply With Quote
  #13  
Old 03-02-2010, 07:39 AM
hayaldunya hayaldunya is offline
 
Join Date: Mar 2008
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by xman_79 View Post
I had a similar problem , and :

In my php file i add :

PHP Code:
$myvbcsspath 'css.php?styleid=' $style['styleid'] . '&langid=' LANGUAGEID '&d=' $style['dateline'] . '&td=' $vbulletin->stylevars['textdirection']['string'] . '&sheet='

PHP Code:
$templater->register('myvbcsspath'$myvbcsspath); 
And in my template :
HTML Code:
<link rel="stylesheet" type="text/css" href="{vb:raw myvbcsspath}mytemplate.css" />
*Rebuild style information .

Now it's work .

Look includes/class_core.php , Line 3994
I'm its problem
Reply With Quote
  #14  
Old 04-17-2010, 09:27 PM
Jaxel Jaxel is offline
 
Join Date: Sep 2005
Posts: 1,160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I dont understand the purpose of all this... I just made a template called "media.css" and added the following to the shell of my mod:

Code:
<link rel="stylesheet" type="text/css" href="{vb:raw vbcsspath}media.css" />
Easy. No plugins required.
Reply With Quote
  #15  
Old 04-17-2010, 11:15 PM
CarlitoBrigante's Avatar
CarlitoBrigante CarlitoBrigante is offline
 
Join Date: Nov 2002
Location: Iceland
Posts: 182
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There is now a hook for the original purpose of this thread. As I said, this thread can now be considered obsolete. Now it has become as easy as creating a "yourcss.css" template, adding a plugin in the parse_template hook, and then do something like this in the plugin:

Code:
$template_hook['custom_css_list'] .= ',yourcss.css';
This thread was made for product creators that needed a simple way to attach css to their styles with no need for people installing their stuff to edit their templates.
Reply With Quote
  #16  
Old 08-02-2010, 06:55 PM
TheSupportForum TheSupportForum is offline
 
Join Date: Jan 2007
Posts: 1,158
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

does anyone know how to add a customer template to an existing template for example header

then to insert the code below or above

{vb:raw ad_location.global_header2}
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:55 AM.


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.04110 seconds
  • Memory Usage 2,267KB
  • Queries Executed 20 (?)
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
  • (4)bbcode_code
  • (2)bbcode_html
  • (4)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (5)postbit
  • (6)postbit_onlinestatus
  • (6)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete