Welcome to the navigation

Voluptate dolor ea exercitation minim eiusmod pariatur, adipisicing dolore excepteur officia sint irure laboris esse qui dolor tempor et mollit ad cupidatat dolore velit veniam. Sed fugiat occaecat voluptate sint elit, excepteur labore minim cillum incididunt nulla aliquip non deserunt dolor ea ut in et aliqua, ipsum officia irure dolore

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