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 get the correct root document based on culture (en-GB, nl-NL) etc.
for use in TryFindContent(PublishedContentRequest contentRequest) during a 404.
Is there an easy way to do this?
Otherwise I tried to pick the right one from a property set in each root, like this...
contentRequest.RoutingContext.UmbracoContext.ContentCache.GetAtRoot().First(x => x.DocumentTypeAlias == "root" && x.GetProperty("defaultLanguage").Value == ????
What do I pass in here when its expecting an object?
Martin
Hi Martin,
What if you are dong something like this would it works for you.
contentRequest.RoutingContext.UmbracoContext.ContentCache.GetAtRoot().First(x => x.DocumentTypeAlias == "root" && x.GetPropertyValue<String>("defaultLanguage") == "en")
So you add the expected return value. like string or int and so on.
Hope this helps,
/Dennis
Hi Dennis
Yes, normally thats what I would use, but its not available for some reason!
I was able to cast it this way...
(bool)x.GetProperty("defaultLanguage").Value == true
Which seemed to do the trick, although there's no HasValue/HasProperty methods either, which kindof sucks!
M.
Answered my own question (as I often do). Once I included Umbraco.Web, all of the extension methods appeared... DOH!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How do I use x.GetProperty("property").Value (obj of type IPublishedProperty) in a lambda expr?
I'm trying to get the correct root document based on culture (en-GB, nl-NL) etc.
for use in TryFindContent(PublishedContentRequest contentRequest) during a 404.
Is there an easy way to do this?
Otherwise I tried to pick the right one from a property set in each root, like this...
contentRequest.RoutingContext.UmbracoContext.ContentCache.GetAtRoot().First(x => x.DocumentTypeAlias == "root" && x.GetProperty("defaultLanguage").Value == ????
What do I pass in here when its expecting an object?
Martin
Hi Martin,
What if you are dong something like this would it works for you.
So you add the expected return value. like string or int and so on.
Hope this helps,
/Dennis
Hi Dennis
Yes, normally thats what I would use, but its not available for some reason!
I was able to cast it this way...
(bool)x.GetProperty("defaultLanguage").Value == true
Which seemed to do the trick, although there's no HasValue/HasProperty methods either, which kindof sucks!
M.
Hi Dennis
Answered my own question (as I often do). Once I included Umbraco.Web, all of the extension methods appeared... DOH!
M.
is working on a reply...