Skip to main content

Posts

Showing posts from May, 2015

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.

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"> <article class="common-blog-pos…