forked from umbraco/UmbracoDocs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Per Ploug
committed
Aug 15, 2012
1 parent
1a37efc
commit ccad32a
Showing
13 changed files
with
512 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@inherits umbraco.MacroEngines.DynamicNodeContext | ||
|
||
@* | ||
Model = The current page the macro is executed on | ||
@Model.bodyText | ||
Parameter = collection of parameter values passed from the macro | ||
@Paramter.myParam | ||
*@ | ||
|
||
|
||
|
||
@* The fun starts here *@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@inherits umbraco.MacroEngines.DynamicNodeContext | ||
|
||
@* Check the current page has ancestors *@ | ||
@if (Model.Ancestors().Any()) | ||
{ | ||
<ul> | ||
@* 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.Ancestors().OrderBy("Level")) | ||
{ | ||
<li><a href="@page.Url">@page.Name</a> »</li> | ||
} | ||
|
||
@* Display the current page as the last item in the list *@ | ||
<li>@Model.Name</li> | ||
</ul> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@inherits umbraco.MacroEngines.DynamicNodeContext | ||
|
||
@* | ||
Macro Parameters To Create, for this macro to work: | ||
Show:True Alias:mediaId Name:Media Folder ID Type:MediaCurrent | ||
*@ | ||
|
||
|
||
@if (Parameter.mediaId != null) | ||
{ | ||
@* Get the media folder as a dynamic node *@ | ||
var mediaFolder = Library.MediaById(Parameter.mediaId); | ||
|
||
if (mediaFolder.Children.Any()) | ||
{ | ||
<ul> | ||
@* for each item in children of the selected media folder *@ | ||
@foreach (var mediaItem in mediaFolder.Children) | ||
{ | ||
<li><img src="@mediaItem.umbracoFile" alt="@mediaItem.Name" /></li> | ||
} | ||
</ul> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@inherits umbraco.MacroEngines.DynamicNodeContext | ||
@* | ||
=== Macro Parameters To Create === | ||
Show:True Alias:nodeId Name:Node ID Type:Content Picker | ||
*@ | ||
|
||
|
||
@{ | ||
var startNodeID = Parameter.nodeId; | ||
} | ||
|
||
@if (startNodeID != null) | ||
{ | ||
@* Get the start node as a dynamic node *@ | ||
var startNode = Library.NodeById(startNodeID); | ||
|
||
if (startNode.Children.Where("Visible").Any()) | ||
{ | ||
<ul> | ||
@foreach (var page in startNode.Children.Where("Visible")) | ||
{ | ||
<li><a href="@page.Url">@page.Name</a></li> | ||
} | ||
</ul> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@inherits umbraco.MacroEngines.DynamicNodeContext | ||
|
||
|
||
@* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@ | ||
@if (Model.Children.Where("Visible").Any()) | ||
{ | ||
<ul> | ||
@* For each child page under the root node, where the property umbracoNaviHide is not True *@ | ||
@foreach (var childPage in Model.Children.Where("Visible")) | ||
{ | ||
<li> | ||
<a href="@childPage.Url">@childPage.Name</a> | ||
</li> | ||
} | ||
</ul> | ||
} |
23 changes: 23 additions & 0 deletions
23
Stubs/cshtml/ListChildPagesFromCurrentPageByDoctype.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@inherits umbraco.MacroEngines.DynamicNodeContext | ||
|
||
@* | ||
Macro Parameters To Create | ||
Show:True Alias:contenType Name:Document Type Type:Textstring | ||
*@ | ||
|
||
@{ | ||
|
||
@*Build a query and return the visible items *@ | ||
string query= "NodeTypeAlias == \"" + Parameter.contentType + "\""; | ||
var selection= Model.Children.Where(query).Where("Visible"); | ||
} | ||
|
||
@*Determine if there are any nodes in the selection, then render list *@ | ||
@if(selection.Any()){ | ||
<ul> | ||
@foreach(var page in selection){ | ||
<li><a href="@page.Url">@page.Name</a></li> | ||
} | ||
</ul> | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@inherits umbraco.MacroEngines.DynamicNodeContext | ||
|
||
@{ | ||
var root = Model.AncestorsOrself(1) | ||
} | ||
|
||
<ul> | ||
@foreach (var page in root.Children.Where("Visible")) | ||
{ | ||
<li><a href="@page.Url">@page.Name</a></li> | ||
} | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@inherits umbraco.MacroEngines.DynamicNodeContext | ||
|
||
|
||
<ul> | ||
@*OrderBy() takes the property to sort by and optionally order desc/asc *@ | ||
@foreach (var page in Model.Children.Where("Visible").OrderBy("CreateDate desc")) | ||
{ | ||
<li><a href="@page.Url">@page.Name</a></li> | ||
} | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@inherits umbraco.MacroEngines.DynamicNodeContext | ||
|
||
|
||
<ul> | ||
@*OrderBy() takes the property to sort by*@ | ||
@foreach (var page in Model.Children.Where("Visible").OrderBy("Name")) | ||
{ | ||
<li><a href="@page.Url">@page.Name</a></li> | ||
} | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@inherits umbraco.MacroEngines.DynamicNodeContext | ||
|
||
@* | ||
Macro parameter to be set on the macro | ||
Show:True Alias:propertyAlias Name:Property Alias Type:Textstring | ||
*@ | ||
|
||
|
||
@{ | ||
|
||
@* Get the property alias we want to filter on from the macro parameter *@ | ||
var propertyAlias = Parameter.propertyAlias; | ||
var selection = Model.Children.Where("Visible").OrderBy(propertyAlias) | ||
} | ||
|
||
|
||
<ul> | ||
@foreach (var page in selection) | ||
{ | ||
<li><a href="@page.Url">@page.Name</a></li> | ||
} | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
@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 (CurrentPage.Children.Where("umbracoNaviHide != @0", "True").Any()) | ||
{ | ||
@* Get the first page in the children, where the property umbracoNaviHide is not True *@ | ||
var naviLevel = CurrentPage.Children.Where("umbracoNaviHide != @0", "True").First().Level; | ||
|
||
@* Add in level for a CSS hook *@ | ||
<ul class="level-@naviLevel"> | ||
@* For each child page under the root node, where the property umbracoNaviHide is not True *@ | ||
@foreach (var childPage in CurrentPage.Children.Where("umbracoNaviHide != @0", "True")) | ||
{ | ||
<li> | ||
<a href="@childPage.Url">@childPage.Name</a> | ||
|
||
@* if the current page has any children, where the property umbracoNaviHide is not True *@ | ||
@if (childPage.Children.Where("umbracoNaviHide != @0", "True").Any()) | ||
{ | ||
@* Call our helper to display the children *@ | ||
@childPages(childPage.Children) | ||
} | ||
</li> | ||
} | ||
</ul> | ||
} | ||
|
||
|
||
@helper childPages(dynamic pages) | ||
{ | ||
@* Ensure that we have a collection of pages *@ | ||
if (pages.Any()) | ||
{ | ||
@* Get the first page in pages and get the level *@ | ||
var naviLevel = pages.First().Level; | ||
|
||
@* Add in level for a CSS hook *@ | ||
<ul class="level-@(naviLevel)"> | ||
@foreach (var page in pages.Where("umbracoNaviHide != @0", "True")) | ||
{ | ||
<li> | ||
<a href="@page.Url">@page.Name</a> | ||
|
||
@* if the current page has any children, where the property umbracoNaviHide is not True *@ | ||
@if (page.Children.Where("umbracoNaviHide != @0", "True").Any()) | ||
{ | ||
@* Call our helper to display the children *@ | ||
@childPages(page.Children) | ||
} | ||
</li> | ||
} | ||
</ul> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
@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 = CurrentPage.AncestorsOrSelf.Last(); | ||
} | ||
|
||
@* Ensure that the Root Node has children, where the property umbracoNaviHide is not True *@ | ||
@if (rootNode.Children.Where("umbracoNaviHide != @0", "True").Any()) | ||
{ | ||
@* Get the first page in the children, where the property umbracoNaviHide is not True *@ | ||
var naviLevel = rootNode.Children.Where("umbracoNaviHide != @0", "True").First().Level; | ||
|
||
@* Add in level for a CSS hook *@ | ||
<ul class="level-@naviLevel"> | ||
@* For each child page under the root node, where the property umbracoNaviHide is not True *@ | ||
@foreach (var childPage in rootNode.Children.Where("umbracoNaviHide != @0", "True")) | ||
{ | ||
<li> | ||
<a href="@childPage.Url">@childPage.Name</a> | ||
|
||
@* if the current page has any children, where the property umbracoNaviHide is not True *@ | ||
@if (childPage.Children.Where("umbracoNaviHide != @0", "True").Any()) | ||
{ | ||
@* Call our helper to display the children *@ | ||
@childPages(childPage.Children) | ||
} | ||
</li> | ||
} | ||
</ul> | ||
} | ||
|
||
|
||
@helper childPages(dynamic pages) | ||
{ | ||
@* Ensure that we have a collection of pages *@ | ||
if (pages.Any()) | ||
{ | ||
@* Get the first page in pages and get the level *@ | ||
var naviLevel = pages.First().Level; | ||
|
||
@* Add in level for a CSS hook *@ | ||
<ul class="level-@(naviLevel)"> | ||
@foreach (var page in pages.Where("umbracoNaviHide != @0", "True")) | ||
{ | ||
<li> | ||
<a href="@page.Url">@page.Name</a> | ||
|
||
@* if the current page has any children, where the property umbracoNaviHide is not True *@ | ||
@if (page.Children.Where("umbracoNaviHide != @0", "True").Any()) | ||
{ | ||
@* Call our helper to display the children *@ | ||
@childPages(page.Children) | ||
} | ||
</li> | ||
} | ||
</ul> | ||
} | ||
} |
Oops, something went wrong.