Posts

Showing posts from 2015

Umbraco Forms - Basics

Umbraco Forms Introduction: a) Stores the forms in the /App_Plugins/UmbracoForms/Data/forms/ folder b)  Stores the forms in JSON format c)  Gives each form a GUID, such as: ea-3e73-4b99-9d81-3055149e3c2e.json that can be used to reference the forms. In the main umbraco template add links to,  JQUERY,  Jquery Validation Jquery Unobtrusive Validation EX:    <!-- Javascripts -->     <script src="/js/jquery.min.js"></script>     <script src="/js/bootstrap.min.js"></script> <script src="/scripts/fanoe.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/mvc/5.2.3/jquery.validate.unobtrusive.js"></script> Umbraco Forms, list Forms from Directory: @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using System.Xml.XPath @using Sy

Umbraco 7 Partial View - Main Navigation - C# - Razor - With Home Page

@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;         @* Add in level for a CSS hook *@                       @* For each child page under the home node *@         foreach (var childPage in home.Children)         {   if(childPage.umbracoNaviHide != true) { if (childPage.Children.Any()) {                   <li class="has-child @(childPage.IsAncestorOrSelf(CurrentPage) ? "current-menu-item page_item" : null)"> @if(childPage.DocumentTypeAlias == "LandingPage") { <a href="@childPage.Url">@childPage.navigationName</a> @childPages(childPage.Children) } else { <a href="@childPage.Url">@childPage.navigationName </a> } </li> } else { <

Umbraco 7 - Partial View - Get RSS Feed and Check Status Code - C# - Razor

The following script displays an RSS feed from another web site and first cehcks to see if the feed is available. @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using System.Xml; @{                  var rssFeedTitle = @ViewData["RSStitle"];   var rssFeedURL = @ViewData["RSSURL"];  } @{ <h3>@rssFeedTitle</h3> var request = (HttpWebRequest)WebRequest.Create("https://jobs.gmc-uk.org/rss/rss200_jobs_2965.xml"); request.Method = "HEAD"; try { var response = (HttpWebResponse)request.GetResponse(); //Get the XML from remote URL XmlDocument xml = new XmlDocument(); //URL currently hardcoded - but you could use a macro param to pass in URL xml.Load("" + @rssFeedURL); //Select the nodes we want to loop through //XmlNodeList nodes = xml.SelectNodes("//item[position() <= 3]"); XmlNodeList nodes = xml.SelectNodes("//item"); //Traverse the entir

Umbraco 7 - Partial View - List FAQs - OR List Child Subpages of a particular Document Type

 Umbraco 7: List Child Subpages of a particular Document Type @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @if (CurrentPage.Children("FAQ").Any()) { <div class="toggle-main faq"> @foreach (var childPage in CurrentPage.Children("FAQ")) { <div class="toggle"> <div class="toggle-title"> <!--FAQ title--> <h3><!-- <i class="fa fa-question"></i> -->@childPage.faqquestion</h3> </div> <div class="toggle-content"> <!--FAQ Detail--> <div class="entry-content"> @childPage.faqanswer </div> </div> </div> } </div> }

Umbraco 7 - Partial View Bradcrumbs

 <h1>@CurrentPage.pageTitle</h1>   <nav class="bread-crumb">          <ul class="breadcrumb clearfix">       @foreach(var level in CurrentPage.Ancestors().Where("Visible")) {   <li><a href="@level.Url">@level.Name</a><span class="divider"></span></li>   }   <li>@CurrentPage.Name</li>             </ul>    </nav>

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

Image
Passing a parameter variable from a Template to a Partial View Example - Passing a Page Id to a Partial View. In the example below we are passing 3 page Ids (1090. 1091, 1092) to a partial view.  The Partial View will display the details for each of these nodes on a home page.  See final output below. 1) In your Template: @Html.Partial("HomePageLinksToLandingPages", new ViewDataDictionary{{ "pageId", 1090}}) @Html.Partial("HomePageLinksToLandingPages", new ViewDataDictionary{{ "pageId", 1091}}) @Html.Partial("HomePageLinksToLandingPages", new ViewDataDictionary{{ "pageId", 1092}}) 2) The Partial View: @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ var thisPageId = 1090; var stringPage = @ViewData["pageId"]; thisPageId = Convert.ToInt32(stringPage); } <div class="col-md-4"> <arti

Umbraco Razor A to Z Loop iterate Through Media Folders:

Image
Umbraco Razor A to Z Loop iterate Through Media Folders: @using Examine @using Examine.SearchCriteria @using UmbracoExamine @using System.Xml.XPath @helper DisplayDocImage(string thisExtension) { switch (thisExtension) { case "docx": case "doc": case "rtf": { @Html.Raw("Word Document"); break; } case "xls": case "xlsx": { @Html.Raw("Excel Spreadsheet Document"); break; } case "ppt": case "pps": case "pptx": case "ppsx": { @Html.Raw("Powerpoint Document");

Umbraco Razor - Delete Pages by Category

The following script allows the User to delete a list of Event Pages by selecting a category: The Second Example is the same as the First except the Umbraco Data type is listed in a Dropdown. Demo Example 1: @inherits umbraco.MacroEngines.DynamicNodeContext @using umbraco.cms.businesslogic.web @{ @* 1. Get the Querystring that Contains the Catecory from Part 3 *@ var qdeleteCat = Request["deleteCat"]; /* Filter*/ if (Request["deleteCat"] != null) { qdeleteCat = Request["deleteCat"]; } else { qdeleteCat = ""; } @* ------------------------------------------------------------- *@ @* 2. Get the Querystring that Contains the Confrim from Part 3 *@ var qConfirm = Request["confirmDelete"]; /* Filter*/ if (Request[&q