Domanda

How do you get the root home node of the current site in an Umbraco 6 Multi site install?

The structure is this:

Content
  --Home1
    --About
    --Contact
  --Home2
    --About
    --Contact
  --Home3
    --About
    --Contact
È stato utile?

Soluzione

var root = Model.Content.AncestorOrSelf("[YourHomeNodeDocumentType]");

I'm not sure if this is Umbraco 6 syntax, but what you want is that AncestorOrSelf traveersing call. I have many multi-site-multi-lingual setups and I use that all the time. The "or self" portion is fun, in some cases that "root" node is a page.

Altri suggerimenti

This works a treat

var rootId = (CurrentPage.Path.Split(','))[1];

It depends if you want a Dynamic Object or a strongly typed DynamicNode Object - but I tend to be in favour of doing it the strongly typed way so I rely on

var root = CurrentModel.AncestorOrSelf(1);

Depending on the version of Umbraco 6 you could use

IPublishedContent rootNode = Umbraco.TypedContentAtRoot().FirstOrDefault();

for a site with a single root node or

IEnumerable<IPublishedContent> rootNode = Umbraco.TypedContentAtRoot();

for as site with multiple root nodes as in your case. These will both work for versions closer to the version 7 track.

I typically use:

Model.Content.AncestorOrSelf(1);

or

IPublishedContent topNode = Model.Content.AncestorOrSelf(1);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top