Quick help, CSS file for registered users only

Luxus

Well-known member
For some CSS work I need a global CSS file (not a specific one like account.css), but for registered users only. Meaning the file should never be loaded to the browsers cache of guests, but always be loaded to the browsers cache of registered users.

Does such file exist? If no, is it possible to create one myself?
 
Add something like this to one of globally use templates, such as page_container:
Code:
<xen:if is="{$visitor.user_id}">
<link rel="xenforo_stylesheet" type="text/css" href="registered.css" />
</xen:if>
 
The css loaded is usually related to templates, not permissions. You should use xen require instead of a link though, that way you can create a new template using the ACP:
Code:
<xen:if is="{$visitor.user_id}">
<xen:require css="registered.css" />
</xen:if>
 
Where did you add it?

Arty's suggestion require that you have a file called registered.css in your root directory, my suggestion require you to create a template called registered.css in the ACP. The easiest way to see if it is working is to check your website source, mine would appear in the css.php?css=....., Arty's would appear as a separate line.
 
I've tested it, both methods work fine. I have put that code in page_container template in head section.

Probably you are doing something wrong with selectors.
 
Arty's suggestion require that you have a file called registered.css in your root directory, my suggestion require you to create a template called registered.css in the ACP.
No, both methods include template, not external file. In my code its rel="xenforo_stylesheet", not rel="stylesheet". I'm not sure what the actual difference is, both seem to work exactly the same way.
 
I added both suggestions to the navigation.css template and created a registered.css template. I checked the CSS via Firebug but nothing I posted in the registered.css file has been found.

Edit: Darn it, these conditionals don't work in .css files. I have to use a html template.:oops:
 
Its ok, both methods work fine :)

Do you know what the actual difference is between those methods? There must be something different about them other than syntax.
 
Well, <link> is used by xenforo's page_container template.
HTML:
<link rel="stylesheet" href="css.php?css=xenforo,form,public&amp;style={xen:urlencode $_styleId}&amp;dir={$visitorLanguage.text_direction}&amp;d={$visitorStyle.last_modified_date}" />
 
Yeah, that is the html specification, the syntax Arty suggested above is a xF specific implementation to load templates. As Arty pointed out, both are the same, one is just closer to the html syntax, so it is easier to remember.
 
Top Bottom