position:<vb:if condition="$show['member']">relative<vb:else />absolute</vb:if>;
Announcement
Collapse
No announcement yet.
if statements in .css templates
Collapse
X
-
Do if statements in .css templates work? I'm trying to show something in one area for members and another for guests and the only thing I have to change is the position from absolute to relative but it doesn't seem to be working as planned
Code:Tags: None
-
Create a plugin.
Hook location: cache_templates
Code:if ($vbulletin->userinfo['userid'] > 0) { $var = 'relative'; } if ($vbulletin->userinfo['userid'] == '') { $var = 'absolute' } vB_Template::preRegister('vbulletin.css',array('var' => $var));
At this point you can use the {vb:raw var} in the css as needed. Example:
position:{vb:raw var};
Comment
-
Originally posted by Andy View PostCreate a plugin.
Hook location: cache_templates
Code:if ($vbulletin->userinfo['userid'] > 0) { $var = 'relative'; } if ($vbulletin->userinfo['userid'] == '') { $var = 'absolute' } vB_Template::preRegister('vbulletin.css',array('var' => $var));
At this point you can use the {vb:raw var} in the css as needed. Example:
position:{vb:raw var};
But holy ****, why wouldn't they let the standard conditionals available in the CSS templates, since they are now seperate tempaltes from the "additional css" box in previous versions.
Comment
-
Originally posted by nforums View PostThanks Andy, that'll work for now.
But holy ****, why wouldn't they let the standard conditionals available in the CSS templates, since they are now seperate tempaltes from the "additional css" box in previous versions.
Good solution Andy... although, I am with Dave in that it would be really, really nice to put conditions directly in the css templates.
Please don't PM or VM me for support - I only help out in the threads.
vBulletin Manual & vBulletin 4.0 Code Documentation (API)
Want help modifying your vbulletin forum? Head on over to vbulletin.org
If I post CSS and you don't know where it goes, throw it into the additional.css template.
W3Schools <- awesome site for html/css help
Comment
-
Originally posted by thincom2000 View PostThe problem with conditionals is that the CSS couldn't be cached in that case. Otherwise people would still be getting the unregistered-user CSS after they've logged in.
Please don't PM or VM me for support - I only help out in the threads.
vBulletin Manual & vBulletin 4.0 Code Documentation (API)
Want help modifying your vbulletin forum? Head on over to vbulletin.org
If I post CSS and you don't know where it goes, throw it into the additional.css template.
W3Schools <- awesome site for html/css help
Comment
-
update for anyone who finds this while searching about using custom variables within the css files - spent a couple hours banging my head against a wall on this as I want to have 1 template across multiple sites, with site-specific customisations done via plugins, including different CSS.
anyway, as of 4.1.0, the plugin (containing the variables) hook location needs to be template_compile not cache_templates.
Comment
Related Topics
Collapse
-
by ibeautyLike in the title. How to format time stamp in template syntax.
I try
{vb:time timestamp} but it displays "2:00" all the time
{vb:time timestamp, His} this don't...-
Channel: Support Issues & Questions
Thu 20 Nov '14, 4:40am -
Comment