Welcome to the navigation

Consequat, nisi pariatur, sit culpa ullamco anim ut aliqua, cupidatat aliquip aute elit, amet, laborum, velit quis mollit ut nulla eiusmod ex reprehenderit commodo esse. In aute ullamco et sint enim nostrud pariatur, mollit qui nisi consectetur est commodo reprehenderit adipisicing ut irure cillum ea velit fugiat duis eiusmod deserunt

Yeah, this will be replaced... But please enjoy the search!

Get a typed object from the uComponents Url Picker

This snippet is based on Umbraco 4.9 and uComponents 5 but should work almost any verison. uComponents for Umbraco is possibly one of the best extensions out there for any CMS and the Url Picker is one of my favorites.

The data returned to the As the documentation states (UrlPicker documentation) you get the data as xml or json.

<url-picker mode="Content">
        <new-window>False</new-window>
        <node-id>1061</node-id>
        <url>/homeorawaytest4.aspx</url>
        <link-title>Home Or Away Quiz</link-title>
</url-picker>

Snippet

I created an object that will help those of who uses c# or vb.net. Use it like this

Node CurrentNode = Node.GetCurrent();
var buyOnlineProperty = CurrentNode.GetProperty("buyOnline");
var buyOnline = new Trikks.Umbraco.UrlPicker(buyOnlineProperty);

And include this object

using System;
using System.Xml;
using umbraco.interfaces;

namespace Trikks.Umbraco
{
    public class UrlPicker
    {
        public string Url { get; set; }
        public int NodeId { get; set; }
        public string LinkTitle { get; set; }
        public bool NewWindow { get; set; }

        public UrlPicker() { }

        public UrlPicker(object property)
        {
            string propertyValue = string.Empty;

            // If IProperty
            if (property is IProperty)
            {
                propertyValue = ((IProperty) property).Value;
            }

            // If string
            if (property is string)
            {
                propertyValue = property.ToString();
            }

            if (!string.IsNullOrEmpty(propertyValue))
            {
                // Get url from xml
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(propertyValue);

                var url = doc.SelectSingleNode("//url");
                if (url != null)
                    Url = url.InnerText;

                var newWindow = doc.SelectSingleNode("//new-window");
                if (newWindow != null)
                    NewWindow = Convert.ToBoolean(newWindow.InnerText);

                var nodeId = doc.SelectSingleNode("//node-id");
                if (nodeId != null && !string.IsNullOrEmpty(nodeId.InnerText))
                    NodeId = Convert.ToInt32(nodeId.InnerText);

                var linkTitle = doc.SelectSingleNode("//link-title");
                if (linkTitle != null)
                    LinkTitle = linkTitle.InnerText;
            }

        }
    }
}

Some results

Using static url

Using Content node picker