asp.net mvc 3 - dynamic theme in MVC3 -
i have been working on mvc3 new project wanted introduce concepts of dynamic themes.
instead of creating bunch of .css files , dynamically linking right one, wanted use <style> section in master <head> section specifies values use selectors , properties.
the values pulled database , written header section in style, this:
<head> <style type="text/css"> .testclass { color:purple;background-color:lightgreen; } </style> </head>
not answer on how achieve end, per se, as suggestion reconsider. have seen approach taken firsthand several times on years, , invariably ends first writing proprietary tool edit database themes , subsequently expensive rewrite extract themes out of database , proper css files.
one typical reason go down path of putting styles in database tends desire allow given style "overridden" on case-by-case basis - instance, in application service provider model, 1 customer wants change 1 or 2 of default styles. however, "cascading" in "cascading style sheets" allows exact behavior, without abandoning goodness of proper css , associated tools - long sequence stylesheets in correct order in page head (e.g. "maintheme.css" first, "customerx.css"), need redefine styles of interest in customer's stylesheet , automatically override in main theme's stylesheet (assuming css selectors otherwise have same precedence).
a related, different reason given going database-driven stylesheets allow end users or business owners edit styles themselves. few exceptions, sort of feature turns out less used , more difficult maintain in practice seems when drawing up. in case, number of styles being customized theoretically quite small - presumably entirely constrained - , you'd writing proprietary tool allow them edited, regardless, again suggest writing out customized styles css file on filesystem, rather database (or blob cdn, etc.).
Comments
Post a Comment