Skip to main content


Umbraco 7 Convert Line Breaks in Text Area when Outputing brs

Recent posts

Umbraco 7 Year Now Razor Snippet

How to display the current year in Razor and in Umbraco 7 

For example:

<p>Copyright &copy; @DateTime.Now.Year </p>

I use this on a lot of my umbraco websites for keeping the copyright up to date.  You can see an example of this on the footer of my most recent Umbraco website design at:

Umbraco 7 HTML Site Map Partial View

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{ var home = CurrentPage.Site(); }

@if (home.Children.Any())
    @* Get the first page in the children *@
    var naviLevel = home.Children.First().Level;
    var listChildPages = "false";

    @* Add in level for a CSS hook *@
    <ul style="margin-top:0px;paddin:0px;font-size:16px;">        
        @* For each child page under the home node *@
        <li><a href="/" title="@CurrentPage._siteTitle">Home</a></li>
        @foreach (var childPage in home.Children.Where("Visible"))
            if (childPage.Children.Any() && listChildPages =="true"  && != 1110)
                <li style="margin-bottom:5px;">
                            <a href="@childPage.Ur…

Umbraco 7 Metadata, Keywords, Description and Title

        var SEOTitle = "";
        var SEODescription = "";
        var SEOKeywords = "";
     @if(CurrentPage.seoTitle != null && CurrentPage.seoTitle != "")
        SEOTitle = CurrentPage.seoTitle;
        SEOTitle = @CurrentPage.Url.Replace("/"," | ") + @CurrentPage._siteTitle;
        SEOTitle = SEOTitle.Substring(2, SEOTitle.Length-2);
     @if(CurrentPage.seoDescription != null && CurrentPage.seoDesctiption != "")
        SEODescription = CurrentPage.seoDescription;
        SEODescription = "This page is about" + @CurrentPage.Url.Replace("/"," ") + @CurrentPage._siteTitle;
     @if(CurrentPage.seoKeywords != null && CurrentPage.seoKeywords != "")
        SEOKeywords = CurrentPage.seoKeywords;
        SEOKeywords = @CurrentP…

Umbraco 7 Hide a page from Navigation or Sub Navigation with umbracoNaviHide using Razor in a template or partial view

How to Allow the user to Hide a Page from Navigation in Umbraco 7. By using a tick box:
This example shows hide the Search Results page from the main navigation in umbraco 7.

1)  In your Document Type add a property called "umbracoNaviHide", it must be called "umbracoNaviHide"

The property should be a tick box, so it should be a "True/False "

2) In your Navigation, add the highlighted code to your for each loop that writes out the navigation:

  @foreach(var p in homePage.Children().Where("visible"))
                            write out navigation

3) Now when the user ticks Hide from Nav in the backend, the page will not show in the navigation:

Umbraco 7 Previous and Next Buttons

This snippet shows Previous and Next  buttons on a page in Umbraco 7

   <div class="nav-previous col-xs-6">
                                    @if(@CurrentPage.Previous() != null)
                                    <h4><a href="@CurrentPage.Previous().Url" rel="prev">PREVIOUS GALLERY</a></h4>
                                    <a href="@CurrentPage.Previous().Url" rel="prev"><span class="meta-nav">←</span> @CurrentPage.Previous().Name</a>

                                <div class="nav-next col-xs-6 pull-right">
                                    @if(@CurrentPage.Next() != null)
                                    <h4><a href="@CurrentPage.Next().Url" rel="next">NEXT GALLERY&…

Umbraco 7 Get the Text and Value from a Radio List

1) This snippet example shows you how to get the Text value of a radio list option in Umbraco 7:


2 ) This snippet example shows you how to get the Value of a radio list option in Umbraco 7:


note:  "optionalLayouts" is the field name in the Umbraco back end in this example.