Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 16 May 2010, 15:55
Jacob_ITAPros Jacob_ITAPros is offline
 
Join Date: Apr 2010
Lightbulb 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.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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. :-)
Reply With Quote
  #2  
Old 16 May 2010, 16:02
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
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.
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #3  
Old 16 May 2010, 16:06
Jacob_ITAPros Jacob_ITAPros is offline
 
Join Date: Apr 2010
Originally Posted by Lynne View Post
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.

Last edited by Jacob_ITAPros; 16 May 2010 at 16:18.
Reply With Quote
  #4  
Old 16 May 2010, 16:55
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Real name: Zachery Woods
Add your code to the bottom of the head include and be done with it as a normal conditional.
__________________
Looking for ImpEx?
Reply With Quote
  #5  
Old 16 May 2010, 17:04
Jacob_ITAPros Jacob_ITAPros is offline
 
Join Date: Apr 2010
Originally Posted by Zachery View Post
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!
Reply With Quote
  #6  
Old 16 May 2010, 17:05
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Real name: Zachery Woods
$GLOBALS[forumid]
__________________
Looking for ImpEx?
Reply With Quote
  #7  
Old 16 May 2010, 17:15
Jacob_ITAPros Jacob_ITAPros is offline
 
Join Date: Apr 2010
Originally Posted by Zachery View Post
$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.
Reply With Quote
  #8  
Old 16 May 2010, 17:30
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Real name: Zachery Woods
That looks fine, give it a shot? what do you have to lose?
__________________
Looking for ImpEx?
Reply With Quote
  #9  
Old 16 May 2010, 17:40
Jacob_ITAPros Jacob_ITAPros is offline
 
Join Date: Apr 2010
Originally Posted by Zachery View Post
That looks fine, give it a shot? 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.
Reply With Quote
  #10  
Old 16 May 2010, 17:51
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Real name: Zachery Woods
Just put it in the headinclude template, why are we being so complicated?
__________________
Looking for ImpEx?
Reply With Quote
  #11  
Old 16 May 2010, 17:56
Jacob_ITAPros Jacob_ITAPros is offline
 
Join Date: Apr 2010
Originally Posted by Zachery View Post
Just put it in the headinclude template, why are we being so complicated?
I've tried that as well. I placed:

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

At the bottom of the headinclude template and still nothing.

When removing the conditional, the file is included. So there is something up with the conditional.

Also, when just trying $foruminfo[forumid], it doesn't work. wtf

--------------- Added 16 May 2010 at 20:21 ---------------

It appears that regardless of the reference, the forumid variable is not rendered whether using

$foruminfo[forumid]
$GLOBALS[forumid]
or just $forumid

I've tried everything in the headerinclude and headerinclude_bottom templates. I've also tried registering $forumid @ forumdisplay_start


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

My next step is to try forumhome and forumdisplay templates. If it works there, then I'll make the assumption that there is no access to this variable in the headers and that there is no definition of this variable with a global scope. Even if that was the case I'm not sure why the plugin above didn't register the variable.

It was asked earlier why this is being made complicated. I'd like to ask the same thing at this point.

Last edited by Jacob_ITAPros; 16 May 2010 at 20:21. Reason: Auto-Merged DoublePost
Reply With Quote
  #12  
Old 16 May 2010, 20:46
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
I just plugged this in and it worked just fine:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And this works just fine in the FORUMDISPLAY template:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #13  
Old 16 May 2010, 21:20
kall's Avatar
kall kall is offline
 
Join Date: Apr 2004
Real name: Ace
Sounds like Jacob is running into the same issue many people have faced - "Why aren't the standard vB Variables available to all templates?" (or my version - "How on earth do I get $forum[forumid] to be recognised outside of FORUMDISPLAY?")
__________________
vBulletin Styles (All styles compatible with 3.8.4 - Steel Blue 4.0 Available) | vBulletin Hosting
Reply With Quote
  #14  
Old 16 May 2010, 21:30
Jacob_ITAPros Jacob_ITAPros is offline
 
Join Date: Apr 2010
Originally Posted by Lynne View Post
I just plugged this in and it worked just fine:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And this works just fine in the FORUMDISPLAY template:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.
Well then I'm losing my mind because apparently I can't get $forumid to be read from anywhere except forumhome_forumbit_level2_post and similar templates.

Even in the FORUMHOME or FORUMDISPLAY templates, I add this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And it does not work. If I remove the conditional and just leave the center action, it works. What in the frack. I'm stumped.

--------------- Added 16 May 2010 at 21:35 ---------------

Originally Posted by kall View Post
Sounds like Jacob is running into the same issue many people have faced - "Why aren't the standard vB Variables available to all templates?" (or my version - "How on earth do I get $forum[forumid] to be recognised outside of FORUMDISPLAY?")
Kall, I can't even get FORUMDISPLAY to read $forumid in a conditional but it appears that it's read as a variable when referenced as: foruminfo.forumid - just fine.

Last edited by Jacob_ITAPros; 16 May 2010 at 21:35. Reason: Auto-Merged DoublePost
Reply With Quote
  #15  
Old 16 May 2010, 22:31
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
It's not going to work on FORUMHOME because there is no single forumid. But, what I wrote definitely works on my 4.0.3 test board in the FORUMDISPLAY template. I have a pink background only in forumid 4. And, the plugin also works for me on my 4.0.3 test board.
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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


New To Site? Need Help?

All times are GMT. The time now is 14:42.

Layout Options | Width: Wide Color: