1. 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

Discussion in 'Styling and Customization Questions' started by Luxus, Sep 19, 2012.

  1. Luxus

    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?
     
  2. Arty

    Arty Well-Known Member

    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>
     
    Luxus likes this.
  3. Luxus

    Luxus Well-Known Member

    Ah, I see. So such file doesn't exist by default, right?
     
  4. MagnusB

    MagnusB Well-Known Member

    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>
     
    Luxus likes this.
  5. Luxus

    Luxus Well-Known Member

    I tried both suggestions but none of them worked.
     
  6. MagnusB

    MagnusB Well-Known Member

    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.
     
  7. Arty

    Arty Well-Known Member

    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.
     
  8. Arty

    Arty Well-Known Member

    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.
     
    MagnusB likes this.
  9. Luxus

    Luxus Well-Known Member

    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:
     
  10. MagnusB

    MagnusB Well-Known Member

    Ahh, I should probably have read your code, I just saw the link rel and never paid much more attention to it.
     
  11. Arty

    Arty Well-Known Member

    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.
     
  12. MagnusB

    MagnusB Well-Known Member

    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.
     
  13. Arty

    Arty Well-Known Member

    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.
     
    MagnusB likes this.
  14. MagnusB

    MagnusB Well-Known Member

    That probably explains why I've never seen it, I don't use WebDav.
     
  15. Luxus

    Luxus Well-Known Member

    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}" />
     
  16. MagnusB

    MagnusB Well-Known Member

    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.
     

Share This Page