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

Variables in CSS template

Discussion in 'XenForo Development Discussions' started by MOZ, Mar 6, 2013.

  1. MOZ

    MOZ Well-Known Member

    Working on an addon, the need arised to generate a CSS from a table in the DB much like how the smilie sprites are generated. I was looking at how to use variables inside css templates, but I searched but got no result.

    However what I realised was that in XenForo_CssOutput::renderCss, there were a handful of variables being passed when CSS is rendered (They aren't using MVC for this, to speed things up). Now if I understand correctly it is impossible to extend this method?

    However out of the available variables, one is $xenOptions. So we can store out data in $xenOptions as a pseudo option (Option that is text type with an empty template defined as option format) , meaning store data in pseudo option, define fetch options value and use in css template. Enjoy!

    Now, for the big question, this is one way of doing it, second way of achieving the same is a little hackish. This is to generate the complete CSS and store it in styles folder upon editing/deleting actions (On the data in the DB) and then use temple_hook/post_render to add the link href to the css.

    Which method is better in your opinion?
  2. James

    James Well-Known Member

  3. MOZ

    MOZ Well-Known Member

    Saw that thread, there wasn't a solution in there.
  4. MOZ

    MOZ Well-Known Member

    Update: no need for serialization/unserialization, just have Option as Array type
  5. MOZ

    MOZ Well-Known Member

    Thoughts anyone?

Share This Page