Skip to content

Instantly share code, notes, and snippets.

View warrenbuckley's full-sized avatar

Warren Buckley warrenbuckley

View GitHub Profile
@warrenbuckley
warrenbuckley / NewsFeed.cshtml
Created February 1, 2012 17:27
Umbraco V5 Example - News feed from News List (atom and rss)
@*
================= Credit goes to Jorge Lusar for creating this =================
Original's at: https://gist.github.com/jorgelusar
Parameters
FeedItems (int, optional, default 20, number of items to be displayed)
FeedTitle (string, optional, default domain name, the title of the feed)
FeedDescription (string, optional, default domain name, the description of the feed)
Author (string, optional, default 'admin', the author name or website name to ensure the atom feed is valid)
@warrenbuckley
warrenbuckley / gist:1933587
Created February 28, 2012 16:48
Umbraco V5 Example - [MODEL] Loop Children ordered by Name
//Order by Node Name
@foreach (Content child in Model.ChildContent().OrderBy(x => x.Name))
{
<h2>@child.Name</h2>
}
//Order by custom property on node with alias of 'pageTitle'
@foreach (Content child in Model.ChildContent().OrderBy(x => x.Field("pageTitle")))
{
<h2>@child.Name</h2>
@warrenbuckley
warrenbuckley / gist:1957541
Created March 2, 2012 10:19
List Child pages from site root (1st level)
@inherits PartialViewMacroPage
@using Umbraco.Cms.Web
@using Umbraco.Cms.Web.Macros
@using Umbraco.Framework
@{
@* Walk up the tree from the current page to get the root node *@
var rootNode = DynamicModel.AncestorsOrSelf.Last();
}
@warrenbuckley
warrenbuckley / gist:1957689
Created March 2, 2012 10:52
List Child Nodes from CurrentPage
@inherits PartialViewMacroPage
@using Umbraco.Cms.Web
@using Umbraco.Cms.Web.Macros
@using Umbraco.Framework
@* Ensure that the rootNode has children, where the property umbracoNaviHide is not True *@
@if(DynamicModel.Children.Where("umbracoNaviHide != @0", "True").Any())
{
<ul>
@warrenbuckley
warrenbuckley / gist:1957921
Created March 2, 2012 11:36
List Child Pages From CurrentPage By Doctype
@inherits PartialViewMacroPage
@using Umbraco.Cms.Web
@using Umbraco.Cms.Web.Macros
@using Umbraco.Framework
@{
@* Get the content type alias we want to filter on from the macro parameter *@
var contentTypeAlias = Model.MacroParameters.contentTypeAlias;
}
@warrenbuckley
warrenbuckley / gist:1958307
Created March 2, 2012 13:12
ListAllDescendatsFromCurrentPage
@inherits PartialViewMacroPage
@using Umbraco.Cms.Web
@using Umbraco.Cms.Web.Macros
@using Umbraco.Framework
@* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@
@if (DynamicModel.Children.Where("umbracoNaviHide != @0", "True").Any())
{
@* Get the first page in the children, where the property umbracoNaviHide is not True *@
@warrenbuckley
warrenbuckley / gist:1958517
Created March 2, 2012 13:52
List ChildPages Ordered By Date Created (Desc)
@inherits PartialViewMacroPage
@using Umbraco.Cms.Web
@using Umbraco.Cms.Web.Macros
@using Umbraco.Framework
@* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@
@if(DynamicModel.Children.Where("umbracoNaviHide != @0", "True").Any())
{
<ul>
@warrenbuckley
warrenbuckley / gist:2065415
Created March 17, 2012 21:25
Work In Progress - JSON Content Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
//WB Added
using Umbraco.Cms.Web;
using Umbraco.Cms.Web.Context;
using Umbraco.Framework.Persistence.Model.Associations;
@warrenbuckley
warrenbuckley / GeneralProperties.cshtml
Created March 29, 2012 15:42
Umbraco V5 (Partial) - General Properties in @DynamicModel
@inherits RenderViewPage
@using Umbraco.Cms.Web;
<h2>Built in Properties</h2>
<h4>Common</h4>
<p>
<strong>@@DynamicModel.Name</strong><br/>
@DynamicModel.Name
</p>
<p>
@warrenbuckley
warrenbuckley / gist:2294862
Created April 3, 2012 19:19
Umbraco V5.1 Relate Member to Node with Relation - MVC Controller
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Umbraco.Framework;
using Umbraco.Cms.Web;
using Umbraco.Cms.Web.Context;
using Umbraco.Framework.Persistence.Model.Associations;
using Umbraco.Hive;
using Umbraco.Hive.RepositoryTypes;