Accessing a root "config" document type from withi...
# help-with-umbraco
m
I created a root content node for meta data (title, description etc). I now need to access these properties from within the master.cshtml - I went through the options in Model but cannot seem to find how to obtain the data. I assume it's a Parent / Root of the page model - Any advice?
j
Assuming a structure like this: - Site rootnode -- Homepage -- Articles --- Article - Settings And you want to access settings from the master template from any child node of the Site rootnode you could traverse to that and then get its sibling.
Copy code
csharp
var site = Model.AncestorOrSelf<ContentModels.Site>();
    var settings = site?.Siblings<ContentModels.Settings>().FirstOrDefault();
d
A nice shortcut to the topmost ancestor is the
.Root()
extension method. In addition to Jemayn's answer.
2 Views