-
Notifications
You must be signed in to change notification settings - Fork 14
Usage
Jeavon edited this page Aug 24, 2016
·
6 revisions
@using UrlPicker.Umbraco.Models
@if (Model.Content.HasValue("widgetLink"))
{
var widgetLink = Model.Content.GetPropertyValue<UrlPicker>("widgetLink");
var linkTarget = widgetLink.Meta.NewWindow ? "_blank" : null;
var linkUrl = widgetLink.Url;
var linkText = widgetLink.Meta.Title;
if (widgetLink.Type == UrlPicker.UrlPickerTypes.Url)
{
if (!string.IsNullOrEmpty(linkUrl) && !(linkUrl.StartsWith("http://") && !(linkUrl.StartsWith("https://"))))
{
linkUrl = "http://" + linkUrl;
}
}
if (!string.IsNullOrEmpty(linkUrl))
{
<a href="@linkUrl" target="@linkTarget">@linkText</a>
}
}
@if (Model.Content.HasValue("footerLinks"))
{
foreach (var link in Model.Content.GetPropertyValue<IEnumerable<UrlPicker>>("footerLinks"))
{
var linkTarget = link.Meta.NewWindow ? "_blank" : null;
var linkUrl = link.Url;
var linkText = link.Meta.Title;
if (link.Type == UrlPicker.UrlPickerTypes.Url)
{
if (!string.IsNullOrEmpty(linkUrl) && !(linkUrl.StartsWith("http://") && !(linkUrl.StartsWith("https://"))))
{
linkUrl = "http://" + linkUrl;
}
}
if (!string.IsNullOrEmpty(linkUrl))
{
<a href="@linkUrl" target="@linkTarget">@linkText</a>
}
}
}
@if (Model.Content.WidgetLink != null)
{
var linkTarget = Model.Content.WidgetLink.Meta.NewWindow ? "_blank" : null;
var linkUrl = Model.Content.WidgetLink.Url;
if (Model.Content.WidgetLink.Type == UrlPicker.UrlPickerTypes.Url)
{
if (!string.IsNullOrEmpty(linkUrl) && !(linkUrl.StartsWith("http://") && !(linkUrl.StartsWith("https://"))))
{
linkUrl = "http://" + linkUrl;
}
}
if (!string.IsNullOrEmpty(linkUrl))
{
<a href="@linkUrl" target="@linkTarget">@Model.Content.WidgetLink.Meta.Title</a>
}
}
@if (Model.Content.FooterLinks != null)
{
foreach (var link in Model.Content.FooterLinks)
{
var linkTarget = link.Meta.NewWindow ? "_blank" : null;
var linkUrl = link.Url;
if (link.Type == UrlPicker.UrlPickerTypes.Url)
{
if (!string.IsNullOrEmpty(linkUrl) && !(linkUrl.StartsWith("http://") && !(linkUrl.StartsWith("https://"))))
{
linkUrl = "http://" + linkUrl;
}
}
if (!string.IsNullOrEmpty(linkUrl))
{
<a href="@linkUrl" target="@linkTarget">@link.Meta.Title</a>
}
}
}