• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Quick help, CSS file for registered users only

Luxus

Well-known member
#1
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?
 

Arty

Well-known member
#2
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>
 

MagnusB

Well-known member
#4
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>
 

MagnusB

Well-known member
#6
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.
 

Arty

Well-known member
#7
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

Well-known member
#8
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.
 

Luxus

Well-known member
#9
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:
 

Arty

Well-known member
#11
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.
 

MagnusB

Well-known member
#12
I have no idea. I just see that the xen:require is the most commonly used in template files. I have not seen the link method used at all.
 

Arty

Well-known member
#13
Found it in template model. They are identical. <link> is used in WebDav output for easy editing, but its stored as <xen:require> in templates.
 

Luxus

Well-known member
#15
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}" />
 

MagnusB

Well-known member
#16
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.