0
votes

I have multiple sites residing inside one umbraco CMS for one client. The sites has many design items in common but the designer had to make one shared css file with a few different ones specific to each site.

Now, I ran into a problem with selecting the relevant css file for a site page. If a user is viewing page1 on site X then I must use css X, but if the user is viewing page1 on site Y I must use css Y.

Any idea how to do it? I thought about using Razor inside the template and check the domain name or the homepage doctype for that domain, any better ideas?

2

2 Answers

2
votes

You may want to check this answer to microsite in umbraco. It gives a pretty good explanation on how to style different sites within the same Umbraco instance. It's mostly geared towards master pages, but it should apply razor views as well.

0
votes

I recommend using razor to find what site you are on. You most probably have several "site" nodes at your root with managed hostnames (I'm guessing here). Create a macro to include your stylesheets and using naming conventions, include both specific and generic stylesheets.

<umbraco:Macro ID="Macro1" Alias="Stylesheets" runat="server" />

Then the macro:

var site = CurrentModel.AncestorOrSelf("Site");
<link rel="stylesheet" type="text/css" href="/css/generic.css" media="all" />
<link rel="stylesheet" type="text/css" href="/site/@site.Name.css" media="all" />

You can do the same thing with javascript files if you need.