vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Conditional Plugin for additional.css (https://vborg.vbsupport.ru/showthread.php?t=242639)

Jacob_ITAPros 05-16-2010 01:55 PM

Conditional Plugin for additional.css
 
I'm attempting to create a plugin that will check certain conditions before appending css to additional.css. Here is what I have for a plugin at hook: cache_templates.

Code:

if in_array($foruminfo['forumid'] == array(2,7)) {
  $sp_css = array
  (
  ".forumbit_post .foruminfo {;",
  " width: 57%;",
  " min-width: 30%;",
  " float: {vb:stylevar left};",
  " clear: {vb:stylevar right};",
  " min-height: 85px;",
  "}"
  )

  foreach ($sp_css as $value) {
  echo $value;
  }


vB_Template::preRegister('additional.css',array('sp_css' => $sp_css))

If there is a way that I can have the array in this plugin display each element I think this would work. The goal in this particular experiment would be, if specfic forum ID's are matched, add these lines to additional.css. Obviously what I have here isn't working.

I'm completely new to PHP and vBulletin so be nice. :-)

Lynne 05-16-2010 02:02 PM

Why not just create a new css template and just perform your condition and then decide to include the css template or not, rather than appending it to another css template.

Jacob_ITAPros 05-16-2010 02:06 PM

Quote:

Originally Posted by Lynne (Post 2037950)
Why not just create a new css template and just perform your condition and then decide to include the css template or not, rather than appending it to another css template.

So in your suggested scenario, the condition would be added at the bottom of the header inlcude, and the css that is in that file would successfully override the css that I'm attempting to reassign values to?

***EDIT***
Actually I'm not sure that header include is the best place. I only need to override specific css elements that are in forum.php and forumdisplay.php. So I don't need this condition checked on every page.

Zachery 05-16-2010 02:55 PM

Add your code to the bottom of the head include and be done with it as a normal conditional.

Jacob_ITAPros 05-16-2010 03:04 PM

Quote:

Originally Posted by Zachery (Post 2037977)
Add your code to the bottom of the head include and be done with it as a normal conditional.

Since the condition is based on $foruminfo['forumid'], and this condition would be added to header include per your suggestion, when I encounter a page in which this variable is not recognized, won't I get an error? That's why I thought that maybe adding this particular conditional in FORUMHOME and FORUMDISPLAY just under the {vb:raw headinclude_bottom} statement might be appropriate. I'm only desiring to override a few structures in forumbit.css for certain forums and subforums.

I appreciate the help and advice so far!

Zachery 05-16-2010 03:05 PM

$GLOBALS[forumid]

Jacob_ITAPros 05-16-2010 03:15 PM

Quote:

Originally Posted by Zachery (Post 2037982)
$GLOBALS[forumid]

Syntax check...the css isn't being inlcuded.

<vb:if condition="in_array($GLOBALS[forumid], array(9,11))">
<link rel="stylesheet" type="text/css" href="/clientscript/vbulletin_css/myfolder/mycss.css" />
</vb:if>

I'm sorry for the nickel and diming.

Zachery 05-16-2010 03:30 PM

That looks fine, give it a shot? :p what do you have to lose?

Jacob_ITAPros 05-16-2010 03:40 PM

Quote:

Originally Posted by Zachery (Post 2037998)
That looks fine, give it a shot? :p what do you have to lose?

No I mean I placed that code in the headinclude_bottom template just above the statement:

{vb:raw template_hook.headinclude_bottom_css}

And the css file is not being included. I used firebug as well and can't find the inclusion of this file when hitting forum and forumdisplay.
:(

Zachery 05-16-2010 03:51 PM

Just put it in the headinclude template, why are we being so complicated? :p


All times are GMT. The time now is 04:59 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.01614 seconds
  • Memory Usage 1,737KB
  • 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
  • (1)bbcode_code_printable
  • (4)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