Skip to content

Instantly share code, notes, and snippets.

View carlosmartinezt's full-sized avatar

Carlos Martinez Tuanama carlosmartinezt

View GitHub Profile
public class ContactController : Umbraco.Web.Mvc.SurfaceController
{
[ChildActionOnly]
public ActionResult ContactForm()
{
var model = new ContactModel();
//Initialize model however you want
model.FullName = "Enter your name";
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
var home = Model.Content.AncestorsOrSelf().First();
}
@helper Traverse(IPublishedContent node, int pad)
{
<li>
<a href="@node.Url">@(!String.IsNullOrWhiteSpace(node.GetPropertyValue<string>("pageName")) ? node.GetPropertyValue<string>("pageName") : !String.IsNullOrWhiteSpace(node.GetPropertyValue<string>("pageTitle")) ? node.GetPropertyValue<string>("pageTitle") : node.Name)</a>
@inherits UmbracoTemplatePage
@{
var mediaFolderId = (int)CurrentPage.BannersMediaFolder;
}
@if (mediaFolderId > 0)
{
var mediaFolder = Umbraco.TypedMedia(mediaFolderId);
var banners = mediaFolder.Children(x => x.DocumentTypeAlias == "Banner").ToList();
@inherits UmbracoTemplatePage
@{
var mediaFolderId = (int)CurrentPage.BannersMediaFolder;
}
@if (mediaFolderId > 0)
{
var mediaFolder = Umbraco.TypedMedia(mediaFolderId);
var banners = mediaFolder.Children(x => x.DocumentTypeAlias == "Banner").ToList();
@if (Model.Content.Parent != null && Model.Content.Level > 2)
{
<a href="@Model.Content.Parent.Url" class="button back-button">Back</a>
}
@if (Model.Content.Ancestors().Any())
{
<div class="breadcrumb">
<ul class="none">
@* For each page in the ancestors collection which have been ordered by Level (so we start with the highest top node first) *@
@foreach (var page in Model.Content.Ancestors().OrderBy("Level"))
{
<li><a href="@page.Url">@page.Name</a></li>
}
@* Display the current page as the last item in the list *@
@{
varhomeNode = Model.Content.AncestorsOrSelf().First();
}
<ul class="none topmenu">
@foreach (var node in homeNode.Children.Where(n => n.GetPropertyValue("hideTopMenu") == false)) {
<li><a href="@node.Url">@node.Name</a>
@if (node.DocumentTypeAlias == "Developments" && node.Children.Any()) {
<div class="submenu">
<ul>
@foreach(var subNode in node.Children)