URL Picker

If you've ever been in the situation where someone demands:
"I want that link to point to either another website or a page in this website or a media item or a file I can upload"
then this datatype is the answer to that very annoying demand.

User Facing

It allows the user to select where they want the URL to come from, either a
  • hand typed URL
URL.PNG
  • content node
Content.PNG
  • media node
Media.PNG
  • or a file upload
Upload-before.PNG Upload-after.PNG

Settings

The four modes are "URL, Content, Media, Upload". These modes can be allowed or disallowed in the prevalue editor:

Prevalues.PNG

Through the settings, the user can be given a very small subset of options:

Restricted.PNG

Developer facing

A URL is always returned when possible, if a node is selected then that node ID is returned also, and the user can specify a title and whether the link opens in a new window.

The data can be saved in CSV, XML or JSON format (the future!), the three looking like this respectively:

Content,False,1061,/homeorawaytest4.aspx,Home Or Away Quiz
(where the headers are "Url Picker Mode, New Window, Node ID, URL, Link Title")

<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>

{
   "Title" : "Home Or Away Quiz",
   "Mode" : 2,
   "NodeId" : 1061,
   "Url" : "/homeorawaytest4.aspx",
   "NewWindow" : false
}

Additionally, if the URL Picker is to be used in a .NET control, you can deserialize any of the above data strings to a strongly typed object - using the static method uComponents.Core.DataTypes.UrlPicker.Dto.UrlPickerState.Deserialize (literal values for the mode are specificed at uComponents.Core.DataTypes.UrlPicker.UrlPickerMode). Nice!

Note to current users: You should be able to upgrade to this version of URL Picker without any data loss from current nodes whatsoever.

Last edited Jan 19, 2012 at 7:41 AM by diachedelic, version 26

Comments

marbledaemon Mar 12 at 7:01 AM 
Can someone tell me why URL Picker property doesn't return Xml string even though its data format is Xml?

The only thing I receive from accessing GetProperty("picker").Value is an unformatted string.

P.S. In the other hand Multi-URL Picker works as intended.

jmontagu Jan 9 at 2:35 AM 
To deseralize this in v5, using Razor:

@using uComponents.DataTypes.UrlPicker.Dto;

var urlPicker = UrlPickerState.Deserialize("foo");

EricHerlitz Oct 12, 2012 at 7:10 PM 
Here is how to get the Url Picker as a typed object, http://trikks.wordpress.com/2012/10/12/get-a-typed-object-from-the-ucomponents-url-picker/

AlexClarity Oct 14, 2011 at 4:01 AM 
Great Work.
Is there a way of getting back the size of the file when you upload a file?

Kriz Jul 22, 2011 at 3:10 PM 
How do I call the url value in razor?

diachedelic Feb 28, 2011 at 1:32 AM 
Hey guys sorry it took so long! I've just updated the codebase with a feature to add link text

leekelleher Dec 9, 2010 at 11:52 AM 
Remember folks, you can add feature requests here: http://ucomponents.codeplex.com/WorkItem/Create

bootnumlock Dec 3, 2010 at 12:20 AM 
+1 on link text field... NICE WORK!

bjawnie Nov 16, 2010 at 9:46 AM 
Excellent. It looks like something I could have used many, many times.

Like Matts says, a field to add a link text, would be a great addition.

mattstueve Nov 16, 2010 at 2:53 AM 
Looks great; is there a way for the user to enter the link text they want to use?