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'm having a problem checking if a Url Picker property is empty or not:
@if (Model.Content.HasValue("announcementLink")) { <h3>Link</h3> if (CurrentPage.announcementLink.XPath("//link-title").InnerText != "") { <i class="icon-link"></i> <a href="@CurrentPage.announcementLink.url" title="@CurrentPage.announcementLink.XPath("link-title").InnerText" target="_blank"> @CurrentPage.announcementLink.XPath("//link-title").InnerText </a> } else { <i class="icon-link"></i> <a href="@CurrentPage.announcementLink.url" title="@CurrentPage.announcementLink.url" target="_blank"> @CurrentPage.announcementLink.url </a> }
Although my link property is empty is still passes this condition:
@if (Model.Content.HasValue("announcementLink"))
Does anyone have an idea how to solve this?
Thanks for your help,
Anthony
Hey Anthony,
Are you using Umbraco v6 and uComponents v6? There is a code sample here
Jeavon
Thanks Jeavon, I upgrade from uComponents 5.5.0 to uComponents 6.0.0. I'm using the property converter and everything works fine now:
@if (Model.Content.HasValue("announcementLink")) { var urlPicker = Model.Content.GetPropertyValue<UrlPickerState>("announcementLink"); if (urlPicker.Url != "") { <h3>Link</h3> if (urlPicker.Title != null) { <i class="icon-link"></i> <a href="@urlPicker.Url" title="@urlPicker.Title" target="_blank"> @urlPicker.Title </a> } else { <i class="icon-link"></i> <a href="@urlPicker.Url" title="@urlPicker.Url" target="_blank"> @urlPicker.Url </a> } } }
the code sample is a great resource!
greetings,
Awesome, that code sample is my only contribution to the uComponents documentation (so far) :-)
I whish there where more code samples like that on uComponents, it was really helpfull. Thanks!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
checking if uComponents Url Pickter is empty
Hi,
I'm having a problem checking if a Url Picker property is empty or not:
Although my link property is empty is still passes this condition:
Does anyone have an idea how to solve this?
Thanks for your help,
Anthony
Hey Anthony,
Are you using Umbraco v6 and uComponents v6? There is a code sample here
Jeavon
Thanks Jeavon, I upgrade from uComponents 5.5.0 to uComponents 6.0.0. I'm using the property converter and everything works fine now:
the code sample is a great resource!
greetings,
Anthony
Awesome, that code sample is my only contribution to the uComponents documentation (so far) :-)
I whish there where more code samples like that on uComponents, it was really helpfull. Thanks!
is working on a reply...