![]() |
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)) { I'm completely new to PHP and vBulletin so be nice. :-) |
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.
|
Quote:
***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. |
Add your code to the bottom of the head include and be done with it as a normal conditional.
|
Quote:
I appreciate the help and advice so far! |
$GLOBALS[forumid]
|
Quote:
<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. |
That looks fine, give it a shot? :p what do you have to lose?
|
Quote:
{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. :( |
Just put it in the headinclude template, why are we being so complicated? :p
|
Quote:
<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. :confused: 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 [DATE]1274041318[/DATE] at [TIME]1274041318[/TIME] --------------- 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 Code:
$forum= array('forumid' => $vbulletin->GPC['forumid']); It was asked earlier why this is being made complicated. I'd like to ask the same thing at this point. |
I just plugged this in and it worked just fine:
PHP Code:
HTML Code:
<vb:if condition="$forumid == 4"> |
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?")
|
Quote:
Even in the FORUMHOME or FORUMDISPLAY templates, I add this: Code:
<vb:if condition="$forumid == 9"> --------------- Added [DATE]1274045759[/DATE] at [TIME]1274045759[/TIME] --------------- Quote:
|
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.
|
Quote:
So I'll be placing the condition in forumhome_forumbit_level2_post, renaming the css structures to something unique in a new css file, and then referencing them in the div where necessary so that they are only used in a specific forum. Fortunately I don't have this very odd forumid issue in the forumhome_forumbit_level2_post template. So the solution for me is to use the very same conditional statement that I've referenced throughout this post, only use it in forumhome_forumbit_level2_post with a new css structure altogether. In the end, it worked out the best for me anyhow. So your help has been appreciated and has also contributed to my effort and for that I'm grateful. Thanks Lynn, talk to you again. --------------- Added [DATE]1274115311[/DATE] at [TIME]1274115311[/TIME] --------------- To bring closure to this thread, my plan worked. :-) Basically I have a conditional in the forumhome_forumbit_level2_post template that uses one set of custom references in divs for certain forum id's, and all other forums which are not designated in the array uses the default layout and css references. The challenge here was that I needed to get all of the forrum-rollup css properties for the set of divs that were targeted for change, and recreate those css structures with properties that emulated that change but with different names. Those changes were added to additional.css. My only setback here is that the same conditional, which is pretty big, has be be placed in one other template so if someone clicks on the forum category, the subsequent forums have the same logic built into them. No biggie, but because the theme of this customization is sponsorship it does mean I will be frequenting these templates when changes occur. Now if I can just add a control panel for this in the ACP that would be hot. But that's a study for another day. Thanks for the help :-) |
All times are GMT. The time now is 03:22 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|