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

Best way to include dynamic CSS?

Discussion in 'XenForo Development Discussions' started by tyteen4a03, Apr 29, 2013.

  1. tyteen4a03

    tyteen4a03 Well-Known Member

    What is the best way to include dynamic CSS in pages? I have a CSS file that is constantly changing due to new data and such, and I have cached it in DataRegistry. I want to serve it via css.php but I'm not sure if I want to bother insert the CSS into the template system.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Shelley likes this.
  3. tyteen4a03

    tyteen4a03 Well-Known Member

  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    ...implemented as a XF CSS template and called via css.php? The CSS can be cached, so don't use conditions in the CSS templates.
     
    xf_phantom likes this.
  5. tyteen4a03

    tyteen4a03 Well-Known Member

    Maybe I should clarify a bit more... I'm using some database-stored data to generate a CSS stylesheet, I'm not sure whether I should write the final stylesheet to a template and <xen:require> the template, or use some hackery to put the CSS in <head> instead.
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    xen:require inside of the content template is the normal method. Either way results in a CSS resource in the head though, and that can be cached. Hence no conditions in the CSS.
     
  7. tyteen4a03

    tyteen4a03 Well-Known Member

    Yeah, I figured injecting them in the <head> is probably OK.
     

Share This Page