I'm looking for a solution to get a custom Value through Multi Url Picker in Umbraco 8. So where my url picker points, I would like to access that page data.
I know I can access to Uid, but I can't figure the next step out.
Like can I I get the Id from Udi maybe, so I can do Umbraco.Content(1337).Value("foo") somehow?
var links = root.Value<IEnumerable<Link>>("links");
if (links.Any())
{
<ul>
@foreach (var link in links)
{
<li><a href="@link.Url" target="@link.Target">@link.Name</a></li>
}
</ul>
}
Hi, thanks for the answer. I think I asked wrong.
I already got this part. My question is that how can I access to other data as well. For example with this Url picker I point to a page, where I have a Title property.
I know I can't do @link.Value("title"), but maybe there is another way.
The other way for me would be to extend the Url Picker with a custom field, but I don't know if it's possible and how.
Specificaly I would like to add an aria-label to Url Picker.
The Link model has a Udi that you can use to get to the linked internal node. External links you will just have to live with the Name that has been entered in the editor. So I'm checking the type, then getting the internal node (the null check is there in case it has been unpublished or deleted). Then check to see if it has a value for the "title" property and use that as the link text.
Try this:
@foreach (var link in links)
{
string linkText = link.Name;
if (link.Type == LinkType.Content)
{
var linkedNode = Umbraco.Content(link.Udi);
if(linkedNode != null && linkedNode.HasValue("title"))
{
linkText = linkedNode.Value<string>("title");
}
}
<li><a href="@link.Url" target="@link.Target">@linkText</a></li>
}
Get data through Multi Url Picker
Hi,
I'm looking for a solution to get a custom Value through Multi Url Picker in Umbraco 8. So where my url picker points, I would like to access that page data. I know I can access to Uid, but I can't figure the next step out. Like can I I get the Id from Udi maybe, so I can do Umbraco.Content(1337).Value("foo") somehow?
at beginig
code
Hi, thanks for the answer. I think I asked wrong. I already got this part. My question is that how can I access to other data as well. For example with this Url picker I point to a page, where I have a Title property.
I know I can't do @link.Value("title"), but maybe there is another way.
The other way for me would be to extend the Url Picker with a custom field, but I don't know if it's possible and how. Specificaly I would like to add an aria-label to Url Picker.
The Link model has a Udi that you can use to get to the linked internal node. External links you will just have to live with the Name that has been entered in the editor. So I'm checking the type, then getting the internal node (the null check is there in case it has been unpublished or deleted). Then check to see if it has a value for the "title" property and use that as the link text.
Try this:
Tim, this is just perfect. Thank you so much for your help!
is working on a reply...