Posts

Showing posts from February, 2014

Umbraco Razor Iterate through Data Type

@using  System.Xml.XPath                                                                   @ {                              XPathNodeIterator  preValueRootElementIterator3  =  umbraco.library.GetPreValues ( 1447 ) ;            preValueRootElementIterator3.MoveNext ( ) ;            XPathNodeIterator  preValueIterator3  =  preValueRootElementIterator3.Current.SelectChildren ( "preValue" ,  "" ) ;                              while  ( preValueIterator3.MoveNext ( ) )            {                @Html.Raw ( ""  +  preValueIterator3.Current.Value ) ;            } }

Umbraco Razor Sort Nodes Ascending or Descending

Descending: @inherits  umbraco.MacroEngines.DynamicNodeContext   @using  umbraco.cms.businesslogic.template ; @foreach ( var  item  in  Model.Children.OrderBy ( "Name descending" ) ) {      if ( item.HasAccess ( ) )      {          @item.Name       } } Ascending: @inherits  umbraco.MacroEngines.DynamicNodeContext   @using  umbraco.cms.businesslogic.template ; @foreach ( var  item  in  Model.Children.OrderBy ( "Name" ) ) {      if ( item.HasAccess ( ) )      {          @item.Name       } }

Umraco Razor Split String - Example Split Tags

Image
In the example Below "tagging" is tags selected by the user: INPUT: CODE: @ {      var  words  =  @Model.tagging.Split ( ',' ) ;       < h2 > My Heading </h2>       foreach  ( string  word  in  words )    {     < p >        @word     < / p >    }        } OUTPUT:

J Query Highlighting Text On Click

<!--  highlight --> <script type="text/javascript"> $("p").click(function(){ $("div").css("visibility", "hidden"); $(this).css("visibility", "visible"); $(this).css("background-color", "yellow"); }); $("p").dblclick(function(){ $("div").css("visibility", "visible"); $(this).css("background-color", ""); }); </script>

Umbraco Display File Extensions as Image Thumbnails, Using Razor

Image
Example Implementation: a) The Helper: @helper DisplayDocImage(string thisExtension) { switch (thisExtension) {     case "docx": case "doc": { <img src="/media/121912/WORD.png" alt="" /> break; } case "xls": case "xlsx": {    <img src="/media/121891/EXCEL.png" alt="" /> break; } case "ppt": case "pptx": {    <img src="/media/121905/PPT.png" alt="" /> break; } case "pdf": {    <img src="/media/121898/PDF.png" alt="" /> break; } default: {   break; } } } b) Calling the Helper: @DisplayDocImage(@thisFile.umbracoExtension)