I'm trying to see if there are any code samples of how to use url picker inside of a block list.
I'm trying this but no joy.
var links3 = Model.Value<IEnumerable<BlockListItem>>("resourceLink");
if (links3.Any())
{
@foreach (var link in links3)
{
<a href="@link.Url" target="@link.Target" class="button-2 _2 w-button">Click here for useful Numbers</a>
}
}
I'm not sure why you are doing a double foreach through the same list. (or is 2nd one a typo & meant to be a different field name?)
Unless there's a nested blocklist field in there that's not reflected in this structure, I am assuming 'resourceLink' is singular and a direct field of 'resourcesList'. If it isn't, then that's probably where the issue is.
Could you use the existing variant iteration to get link field data like the other 2 fields above it? I haven't extracted data from a block list like this before so not totally sure, but if 'resourceLink' is just a field on the same item like the 'resourceDescription' and 'resourceName' are, then have you tried following those as an example? Something like:
...
<p>@variant.Value("resourceDescription")</p>
@{
Link link = variant.Value("resourceLink");
if (!string.IsNullOrWhiteSpace(link?.Url))
{
...
}
}
What have you tried debugging? Have you checked for which stage it's failing at (if checks or empty list)? When you say 'no link' which markup isn't rendering? The entire list-item block or just the @link variables are empty?
Random note, note sure if it's just cause you cleaned this up for ease of reading here, but it looks like your li-tags are missing their parent element ;3 (ul/ol)
URL picker in block list umbraco 12
Hi all,
I'm trying to see if there are any code samples of how to use url picker inside of a block list.
I'm trying this but no joy.
}
Hi, 'Link' is of type Link, not BlockListItem. In the loop, you have to extract the Link from each BlockListItem
Regards
Hi Thanks,
I did the following but I'm not getting any data for my link button, I also get no error messages the page loads fine just no link.
Below is my code
resourcesList is my block list name resourceLink is my URL picker.
Any help is appreciated.
Thanks
I'm not sure why you are doing a double foreach through the same list. (or is 2nd one a typo & meant to be a different field name?)
Unless there's a nested blocklist field in there that's not reflected in this structure, I am assuming 'resourceLink' is singular and a direct field of 'resourcesList'. If it isn't, then that's probably where the issue is.
Could you use the existing variant iteration to get link field data like the other 2 fields above it? I haven't extracted data from a block list like this before so not totally sure, but if 'resourceLink' is just a field on the same item like the 'resourceDescription' and 'resourceName' are, then have you tried following those as an example? Something like:
What have you tried debugging? Have you checked for which stage it's failing at (if checks or empty list)? When you say 'no link' which markup isn't rendering? The entire list-item block or just the @link variables are empty?
Random note, note sure if it's just cause you cleaned this up for ease of reading here, but it looks like your li-tags are missing their parent element ;3 (ul/ol)
is working on a reply...