Posts

Showing posts from March, 2013

Umbraco Razor Display Links to Next, Previous and Parent page or node

The Following Razor code for Umbraco displays Next and Previous Buttons / Links and a Return to the Parent node Button / Link: Example 1: <umbraco:Macro runat="server" language="cshtml">    @{         if (@Model.Previous() != null) {             <a href="@Model.Previous().Url">Previous Image</a> } var currentPg = Model; <a href="@currentPg.Parent.Url">View all @currentPg.Parent.Name</a> if (@Model.Next() != null) {             <a href="@Model.Next().Url">Next Image</a>         }     } </umbraco:Macro> Example 2: This Example shows you how to ignore pages that are hidden from the navigation in Umbraco.    @{ if (@Model.Previous() != null) { var node = Model.Previous(); if (node.Visible) {             <a class="button green"  href="@Model.Previous().Url">@Model.Previous().PageTitle Images</a> }    

Umbraco Inline Razor to refer to Stylesheets within a Template

Umbraco Inline Razor to refer to a Stylesheet Example:  <umbraco:Macro runat="server" language="cshtml"> @{var myStyleSheet = "~/css/styles.css";} <link rel="stylesheet"  href="@Href(myStyleSheet)" type="text/css" media="screen" /> @{var IEStyleSheet = "~/css/stylesIE.css";} <!--[if lte IE 8]> <link rel="stylesheet" href="@Href(myStyleSheet)" type="text/css" media="screen" /> <![endif]--> </umbraco:Macro> Umbraco Inline Razor to refer to lots of Stylesheets, using the folder as the reference Example <umbraco:Macro runat="server" language="cshtml"> @{var myStyleSheetFolder = "~/css/";} <link href=" @Href(myStyleSheetFolder) bootstrap.css" rel="stylesheet">       <link rel="stylesheet" type="text/css" href="