Welcome to the navigation

Non elit, sit incididunt duis ad aliqua, laboris fugiat nulla culpa eiusmod est aliquip sunt reprehenderit do tempor dolore minim ipsum in commodo mollit esse. Et sunt anim occaecat proident, amet, sed in eu veniam, tempor qui ipsum deserunt dolor aute commodo exercitation incididunt cupidatat aliquip in id velit elit

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

 

 

Please note that this portal is a BETA site , I will continuously improve all functionality and performance during the coming weeks / the author