Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm trying to set/access a global site value.
On my HomePage document type I've created a 'site settings' tab, and within this tab I've added a 'postAuthor' property.
On the HomePage I can retrive and show the 'postAuthor' value using @Model.Value("postAuthor").
But, when I use @Model.Value("postAuthor") on the post page, no value is returned?
Below is the content structure, and I would like to use the global value for the author name from the HomePage 'site settings' tab on other pages below the root node?
I've tried different ways, but still cant get thos to work !
You need to get the model for the HomePage node, on your post page, since the properties are defined on it.
Try Model.Root().Value("postAuthor") or Model.Root<HomePage>().PostAuthor if you're using the model builder.
This worked perfectly for what I needed.
I do not use this feature myself, so cant comment on how effective it is, but doesn't Umbraco have a fallback option, when getting a model value? I noticed when I was playing around with the template editor UI:
In your case, it would give you:
@Model.Value("postAuthor", fallback: Fallback.ToAncestors)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted