Shmarman
Shmarman

Reputation: 23

kentico localization macros in CSS

I'm trying to use macros in a CSS file (in site manager-> development).

This is my CSS code:

@import url('/CMSPages/GetResource.ashx?stylesheetname=sitecss{$=|en-US=eng$}');

a, a:visited, a:active {
  color:#407a1f;
}
....

This doesn't seem to work dynamically on the site as I switch between default culture and English.

The only time that it works is if I SAVE the CSS file (in site manager) while the site itself is in a certain culture.

In short: the macro "takes" the culture when the CSS file is saved and is not dynamic upon page loading.

How can I solve this?

THANKS :)

Upvotes: 0

Views: 1125

Answers (2)

mivra
mivra

Reputation: 1400

In version 6 and later you can do it by @import url('/CMSPages/GetResource.ashx?stylesheetname=sitecss{%CurrentCulture%}'); or you can directly resolve target CSS by {% CSS["<stylesheet code name>"] %} See more on http://devnet.kentico.com/docs/devguide/index.html?combining_stylesheets.htm

Upvotes: 0

anar khalilov
anar khalilov

Reputation: 17498

As far as I know, you cannot make you CSS code dynamic. However, you can do this easily as explained below:

  • Kentico adds a special class to the body tag of the document. Check your source code and you will see that the body tag has a class ENUS if the current culture is en-US, ENGB if the current culture is en-GB and so on.
  • Then you can change your CSS code accordingly by defining rules like:
    • body.ENUS .container { float: left; }
    • body.ENGB .container { float: right; }
    • body.FRFR .container { float: none; }

Hope this helps.

Upvotes: 0

Related Questions