I create the archetype field with multiple data like Title image content link. I can get the value for title content value but link show the output.
[ { "name": "View Website", "url": "www.google.com", "target": "_blank", "icon": "icon-link" } ]
How to get the Url from link
@{
var property = Model.Content.GetPropertyValue<ArchetypeModel>("exhibitorLogos");
}
@if (property != null && property.Any()) {
foreach (var item in property)
{
var imageId = item.GetValue<int>("image");
var imgurlbannerLogoUrl = Umbraco.Media(imageId.ToString()).Url;
var text = item.GetValue<string>("name");
var content = item.GetValue<string>("content");
var link = item.GetValue<string>("link");
<h1>@text</h1>
<img src="@imgurlbannerLogoUrl"/>
<p>@content</p>
<a href="@link">ReadMore</a>
}
}
It depends a little on your version of Umbraco and the version of URL Picker you're using, try the below.
Add a using statement:
@using RJP.MultiUrlPicker.Models
Then do one of the below.
Either this:
foreach (var item in property)
{
var imageId = item.GetValue<int>("image");
var imgurlbannerLogoUrl = Umbraco.Media(imageId.ToString()).Url;
var text = item.GetValue<string>("name");
var content = item.GetValue<string>("content");
var link = item.GetValue<Link>("link");
<h1>@text</h1>
<img src="@imgurlbannerLogoUrl"/>
<p>@content</p>
<a href="@link">ReadMore</a>
}
Or this:
foreach (var item in property)
{
var imageId = item.GetValue<int>("image");
var imgurlbannerLogoUrl = Umbraco.Media(imageId.ToString()).Url;
var text = item.GetValue<string>("name");
var content = item.GetValue<string>("content");
var link = item.GetValue<IEnumerable<Link>>("link").FirstOrDefault();
<h1>@text</h1>
<img src="@imgurlbannerLogoUrl"/>
<p>@content</p>
<a href="@link">ReadMore</a>
}
Then you can simply do something like the following:
<a href="@link.Url" target="@link.Target">@link.Name</a>