Posts

Showing posts from November, 2016

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

Image
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>                                                                                                     <div class="nav-next col-xs-6 pull-right">                                     @if( @CurrentPage.Next() != null )                                     {                                     <h4>

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 : @umbraco.library.GetPreValueAsString(CurrentPage.optionalLayouts) 2 ) This snippet example shows you how to get the Value of a radio list option in Umbraco 7 : @CurrentPage.optionalLayouts note:  "optionalLayouts" is the field name in the Umbraco back end in this example.

Umbraco 7 test for Odd and Even rows in a loop to display differenrt coloured rows or sections

The snippet example below shows one way of testing for Odd and Even in an umbraco foreach loop. The result is to list out odd and even background colours, suach as in bootstrap sections. @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{      var count = 0;        var colourClass = ""; }     @foreach(var childPage in Umbraco.Content(1067).Children().Where("NodeTypeAlias == \"newPageSection\""))     {                 if(count% 2 == 0)         {           colourClass="dark";         }         else         {            colourClass="light";         }         <div class="content-block content-block- @colourClass "> // DO some stuff  </div>

Umbraco 7 Check to see if a filed HasVale and check to see if a Field IsNullOr Empty

The snippet below 1) Checks to see if the umbraco Field "sectionVideo" is Null or Empty. 2) Check to see if umbraco field "sectonImage" has a vale @if( String.IsNullOrEmpty(childPage.sectionVideo) && childPage.HasValue("sectionImage") )                         {                         <div class="col-lg-6">                             <img src="@childPage.GetCropUrl("sectionImage","rectangle")" />                         </div>                         }                         else                         {                             if(childPage.HasValue("sectionVideo"))                             {                             <div class="col-lg-6">                                 <div class="product-video"><a class="swipebox-video " rel="vimeo" href="https://vimeo.com/123186702"><img class="img-re