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

Umbracoarmus! Casting your current page object

Imagine this, You have a IPublished content object that you’re using in your view. It is set up like this

var currentPage = Umbraco.CurrentPage();

You can access your property values like so


But when you call any other methods on myProperty such as .HasValue you get an exception as the value throws an exception. Annoying right.
You just need to cast the property as follows


Then you can gain access to the property.

ALL the Shares!!

Customizing the content that you need your users to share on social media couldn’t be easier. I have integrated this with the Umbraco CMS to allow for web administrators to tailor the content that is shared.

Add the following code to your project page and amend accordingly. Once the code is deployed to a publicly accessible URL (This will not work on your localhost!), you will need to run the URL through the following validators to ensure that your content is being found correctly.

Place the following in the head of your page

<meta property=”og:url” content=”@Umbraco.NiceUrlWithDomain(CurrentPage.Id)” />
<meta property=”og:type” content=”article” />
<meta property=”og:title” content=”@CurrentPage.facebook_title” />
<meta property=”og:description” content=”@CurrentPage.facebook_summary” />
<meta property=”og:image” content=”@CurrentPage.MediaFile(“facebook_thumbnail_image”).Replace(“https”, “http”)” />
<meta property=”og:image:secure_url” content=”@CurrentPage.MediaFile(“facebook_thumbnail_image”)” />

<meta name=”twitter:card” content=”photo” />
<meta name=”twitter:site” content=”@Umbraco.NiceUrlWithDomain(CurrentPage.Id)” />
<meta name=”twitter:title” content=”@CurrentPage.Twitter_Title” />
<meta name=”twitter:description” content=”@CurrentPage.twitter_summary” />
<meta name=”twitter:image” content=”@CurrentPage.MediaFile(“twitter_thumbnail_image”)” />
<meta name=”twitter:url” content=”@Umbraco.NiceUrlWithDomain(CurrentPage.Id)” />

Place the links in the body content.

<a href=”@String.Format(“{0}”, Umbraco.NiceUrlWithDomain(CurrentPage.Id))” >Facebook</a>

<a href=”@String.Format(“{0}&media={1}&description={2}”, Umbraco.NiceUrlWithDomain(CurrentPage.Id), CurrentPage.MediaFile(“pintrest_thumbnail_image”), CurrentPage.pintrest_summary)”></a>

<a href=”@String.Format(“{0}”, Umbraco.NiceUrlWithDomain(CurrentPage.Id))”>Twitter></a>