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
Hi,
I am trying to create an unordered list, which will not show if the content editor has not added an items to the list.
I have the following code:
<umbraco:Macro Language="cshtml" runat="server"> @if (@Model.HasProperty("upperListLinks") && @Model.GetProperty("upperListLinks").Value != String.Empty) { <ul class="green_squers"> @foreach (var link in Model.upperListLinks.urlpicker) { <li><a href="@link.url" @Html.Raw(link.newwindow == "True" ? "target=\"_blank\"" : "")>@link.linktitle</a></li> } </ul> } </umbraco:Macro>
Any ideas on how I can get this to work?
Thank you!
If the Multi Url Picker's alias is upperListLinks, then the following should work:
@using umbraco.MacroEngines@inherits DynamicNodeContext@if (Model.upperListLinks.GetType() == typeof(DynamicXml) && Model.upperListLinks.Count() > 0){ <ul class="green_squers"> @foreach (var link in Model.upperListLinks) { <li><a href="@link.url" @Html.Raw(link.newwindow == "True" ? "target=\"_blank\"" : "")>@link.linktitle</a></li> } </ul>}
If the current Model does not have a Multi Url Picker with the alias of upperListLinks, then Model.upperListLinks.GetType() will return a DynamicNull object and the condition will be false.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Check if Multi-URL picker has items
Hi,
I am trying to create an unordered list, which will not show if the content editor has not added an items to the list.
I have the following code:
Any ideas on how I can get this to work?
Thank you!
If the Multi Url Picker's alias is upperListLinks, then the following should work:
If the current Model does not have a Multi Url Picker with the alias of upperListLinks, then Model.upperListLinks.GetType() will return a DynamicNull object and the condition will be false.
is working on a reply...