Related Links!

If you need to combine internal links and external links in the same Umbraco picker, you will need to use the related links picker.

This will generate a JSON array. This is how you extract the links on the other end.


var obj = JsonConvert.DeserializeObject<JArray>(test);

foreach (var a in obj)
var type = a.Value<string>(“type”);

var newWindow = a.Value<bool>(“newWindow”);
var title = a.Value<string>(“title”);

if (type.IsNullOrWhiteSpace() == false)
if (type == “internal”)
var linkId = a.Value<int>(“internal”);
var link = Umbraco.NiceUrl(linkId);
<li><a href=”@link” @(newWindow ? “target=_blank” : “”)>@title</a></li>

if(type == “external”)
var linkTitle = a.Value<string>(“caption”);
var link = a.Value<string>(“link”);
<li><a href=”@link” @(newWindow ? “target=_blank” : “”)>@title</a></li>


public static MvcHtmlString RelatedLinksGenerator(this JToken source, string urlCSS)
var helper = new UmbracoHelper(UmbracoContext.Current);
var type = source.Value(“type”);
var newWindow = source.Value(“newWindow”);
var title = source.Value(“title”);

var anchor = new TagBuilder(“a”);
string link = string.Empty;

var linkId = source.Value(“internal”);
link = helper.NiceUrlWithDomain(linkId);

var linkTitle = source.Value(“caption”);
link = source.Value(“link”);

anchor.MergeAttribute(“href”, link);
anchor.MergeAttribute(“class”, urlCSS);

return MvcHtmlString.Create(anchor.ToString(TagRenderMode.Normal));


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s