Umbraco Razor - One Way to Check to See if A Node or Page Still Exists and or is Published


This can be used, for example, in a Partial View to see if a node is publish and or exists to ensure that the page does not throw an error when trying to write out details from a page or it's sub nodes .


@{
var thisPage = Umbraco.Content(1256); // Get the page
}

@if(thisPage.Path != null && thisPage.Path != "")
{
   // Write out content from that page

 }

Comments

Popular posts from this blog

Umbraco 7 - C# Razor - Passing a parameter variable from a Template to a Partial View.

Umbraco Razor Sort Nodes Ascending or Descending

Umbraco - Reset the Admin Password via SQL Server