Merge branch 'dev-v7' into 7.3.0
This commit is contained in:
@@ -19,12 +19,12 @@
|
||||
ng-class="{last:$last, selected:section==currentSection}"
|
||||
ng-repeat="section in currentLayout.sections"
|
||||
ng-click="configureSection(section, currentLayout)"
|
||||
style="width:{{ percentage(section.grid) }}%">
|
||||
ng-style="{width: percentage(section.grid) +'%'}">
|
||||
</a>
|
||||
|
||||
<a class="td uSky-templates-column add" ng-if="availableLayoutSpace > 0"
|
||||
ng-click="configureSection(undefined, currentLayout)"
|
||||
style="width:{{ percentage(availableLayoutSpace) }}%">
|
||||
ng-style="{width: percentage(availableLayoutSpace) + '%'}">
|
||||
<i class="icon icon-add"></i>
|
||||
</a>
|
||||
|
||||
@@ -113,4 +113,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -20,12 +20,12 @@ ng-controller="Umbraco.PropertyEditors.GridPrevalueEditor.RowConfigController">
|
||||
ng-class="{last:$last, selected:cell==currentCell}"
|
||||
ng-repeat="cell in currentRow.areas"
|
||||
ng-click="configureCell(cell, currentRow)"
|
||||
style="width:{{ percentage(cell.grid) }}%">
|
||||
ng-style="{width: percentage(cell.grid) + '%'}">
|
||||
</a>
|
||||
|
||||
<a class="td uSky-templates-column add"
|
||||
ng-click="configureCell(undefined, currentRow)"
|
||||
style="width:{{ percentage(availableRowSpace) }}%">
|
||||
ng-style="{width: percentage(availableRowSpace) + '%'}">
|
||||
<i class="icon icon-add"></i>
|
||||
</a>
|
||||
</div>
|
||||
@@ -35,7 +35,7 @@ ng-controller="Umbraco.PropertyEditors.GridPrevalueEditor.RowConfigController">
|
||||
<div ng-if="currentCell" style="padding-bottom: 50px;">
|
||||
|
||||
<umb-control-group label="@general_width">
|
||||
<div class="grid-size-scaler" >
|
||||
<div class="grid-size-scaler" >
|
||||
<div class="grid-size-scaler">
|
||||
<a href ng-click="scaleDown(currentCell)">
|
||||
<i class="icon icon-remove"></i>
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
@*
|
||||
This snippet makes a breadcrumb of parents using an unordred html list.
|
||||
This snippet makes a breadcrumb of parents using an unordered html list.
|
||||
|
||||
How it works:
|
||||
- It uses the Ancestors() method to get all parents and then generates links so the visitor get go back
|
||||
- It uses the Ancestors() method to get all parents and then generates links so the visitor can go back
|
||||
- Finally it outputs the name of the current page (without a link)
|
||||
*@
|
||||
|
||||
@if (CurrentPage.Ancestors().Any())
|
||||
@{ var selection = CurrentPage.Ancestors(); }
|
||||
|
||||
@if (selection.Any())
|
||||
{
|
||||
<ul class="breadcrumb">
|
||||
@* 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 CurrentPage.Ancestors().OrderBy("Level"))
|
||||
@foreach (var item in selection.OrderBy("Level"))
|
||||
{
|
||||
<li><a href="@page.Url">@page.Name</a> <span class="divider">/</span></li>
|
||||
<li><a href="@item.Url">@item.Name</a> <span class="divider">/</span></li>
|
||||
}
|
||||
|
||||
@* Display the current page as the last item in the list *@
|
||||
|
||||
@@ -1,31 +1,50 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@*
|
||||
Macro to display a gallery from a media folder. Add the below parameter to the macro
|
||||
and use it to point the macro at a specific media folder to display it's content as
|
||||
a simple list.
|
||||
Macro to display a gallery of images from media the media section.
|
||||
Works with either a 'Single Media Picker' or a 'Multiple Media Picker' macro parameter (see below).
|
||||
|
||||
Macro Parameters To Create, for this macro to work:
|
||||
Alias:mediaId Name:Media Folder ID Type:Single Media Picker
|
||||
How it works:
|
||||
- Confirm the macro parameter has been passed in with a value
|
||||
- Loop through all the media Id's passed in (might be a single item, might be many)
|
||||
- Display any individual images, as well as any folders of images
|
||||
|
||||
Macro Parameters To Create, for this macro to work:
|
||||
Alias:mediaIds Name:Select folders and/or images Type: Multiple Media Picker
|
||||
Type: (note: you can use a Single Media Picker if that's more appropriate to your needs)
|
||||
*@
|
||||
|
||||
@if (Model.MacroParameters["mediaId"] != null)
|
||||
@{ var mediaIds = Model.MacroParameters["mediaIds"]; }
|
||||
@if (mediaIds != null)
|
||||
{
|
||||
@* Get the media folder as a dynamic node *@
|
||||
var mediaFolder = Umbraco.Media(Model.MacroParameters["mediaId"]);
|
||||
<ul class="thumbnails">
|
||||
@foreach (var mediaId in mediaIds.ToString().Split(','))
|
||||
{
|
||||
var media = Umbraco.Media(mediaId);
|
||||
|
||||
if (mediaFolder.Children.Any())
|
||||
{
|
||||
<ul class="thumbnails">
|
||||
@* for each item in children of the selected media folder *@
|
||||
@foreach (var mediaItem in mediaFolder.Children)
|
||||
@* a single image *@
|
||||
if (media.DocumentTypeAlias == "Image")
|
||||
{
|
||||
<li class="span2">
|
||||
<a href="@mediaItem.umbracoFile" class="thumbnail">
|
||||
<img src="@mediaItem.umbracoFile" alt="@mediaItem.Name" />
|
||||
</a>
|
||||
</li>
|
||||
@Render(media);
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
@* a folder with images under it *@
|
||||
if (media.Children("Image").Any())
|
||||
{
|
||||
foreach (var image in media.Children("Image"))
|
||||
{
|
||||
@Render(image);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
@helper Render(dynamic item)
|
||||
{
|
||||
<li class="span2">
|
||||
<a href="@item.umbracoFile" class="thumbnail">
|
||||
<img src="@item.umbracoFile" alt="@item.Name" />
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
@@ -1,16 +1,24 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
@*
|
||||
This snippet makes a list of links to the of parents of the current page using an unordered html list.
|
||||
|
||||
@* Check the current page has ancestors *@
|
||||
@if (CurrentPage.Ancestors().Any())
|
||||
{
|
||||
How it works:
|
||||
- It uses the Ancestors() method to get all parents and then generates links so the visitor can go back
|
||||
- Finally it outputs the name of the current page (without a link)
|
||||
*@
|
||||
|
||||
@{ var selection = CurrentPage.Ancestors(); }
|
||||
|
||||
@if (selection.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 CurrentPage.Ancestors().OrderBy("Level"))
|
||||
@foreach (var item in selection.OrderBy("Level"))
|
||||
{
|
||||
<li><a href="@page.Url">@page.Name</a> »</li>
|
||||
<li><a href="@item.Url">@item.Name</a> »</li>
|
||||
}
|
||||
|
||||
@* Display the current page as the last item in the list *@
|
||||
<li>@CurrentPage.Name</li>
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,33 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@*
|
||||
=== Macro Parameters To Create ===
|
||||
Alias:nodeId Name:Node ID Type:Content Picker
|
||||
Macro to list all child pages under a specific page in the content tree.
|
||||
|
||||
How it works:
|
||||
- Confirm the startNodeId macro parameter has been passed in with a value
|
||||
- Loop through all child pages
|
||||
- Display a list of link to those pages, sorted by the value of the propertyAlias
|
||||
|
||||
Macro Parameters To Create, for this macro to work:
|
||||
Alias:startNodeId Name:Select starting page Type:Content Picker
|
||||
*@
|
||||
|
||||
@if (Model.MacroParameters["startNodeID"] != null)
|
||||
@{ var startNodeId = Model.MacroParameters["startNodeId"]; }
|
||||
@if (startNodeId != null)
|
||||
{
|
||||
@* Get the start node as a dynamic node *@
|
||||
var startNode = Umbraco.Content(Model.MacroParameters["startNodeID"]);
|
||||
|
||||
if (startNode.Children.Where("Visible").Any())
|
||||
@* Get the starting page *@
|
||||
var startNode = Umbraco.Content(startNodeId);
|
||||
var selection = startNode.Children.Where("Visible");
|
||||
|
||||
if (selection.Any())
|
||||
{
|
||||
<ul>
|
||||
@foreach (var page in startNode.Children.Where("Visible"))
|
||||
{
|
||||
<li><a href="@page.Url">@page.Name</a></li>
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li>
|
||||
<a href="@item.Url">@item.Name</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@
|
||||
@if (CurrentPage.Children.Where("Visible").Any())
|
||||
@{ var selection = CurrentPage.Children.Where("Visible"); }
|
||||
|
||||
@if (selection.Any())
|
||||
{
|
||||
<ul>
|
||||
@* For each child page under the root node, where the property umbracoNaviHide is not True *@
|
||||
@foreach (var childPage in CurrentPage.Children.Where("Visible"))
|
||||
<ul>
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li>
|
||||
<a href="@childPage.Url">@childPage.Name</a>
|
||||
<a href="@item.Url">@item.Name</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@{ var selection = CurrentPage.Children.Where("Visible").OrderBy("CreateDate desc"); }
|
||||
@* OrderBy() takes the property to sort by and optionally order desc/asc *@
|
||||
|
||||
<ul>
|
||||
@* OrderBy() takes the property to sort by and optionally order desc/asc *@
|
||||
|
||||
@foreach (var page in CurrentPage.Children.Where("Visible").OrderBy("CreateDate desc"))
|
||||
{
|
||||
<li><a href="@page.Url">@page.Name</a></li>
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li><a href="@item.Url">@item.Name</a></li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
|
||||
|
||||
@{ var selection = CurrentPage.Children.Where("Visible").OrderBy("Name"); }
|
||||
@* OrderBy() takes the property to sort by *@
|
||||
|
||||
<ul>
|
||||
@* OrderBy() takes the property to sort by *@
|
||||
@foreach (var page in CurrentPage.Children.Where("Visible").OrderBy("Name"))
|
||||
{
|
||||
<li><a href="@page.Url">@page.Name</a></li>
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li><a href="@item.Url">@item.Name</a></li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@*
|
||||
Macro parameter to be set on the macro
|
||||
Macro to list all child pages with a specific property, sorted by the value of that property.
|
||||
|
||||
How it works:
|
||||
- Confirm the propertyAlias macro parameter has been passed in with a value
|
||||
- Loop through all child pages that have the propertyAlias
|
||||
- Display a list of link to those pages, sorted by the value of the propertyAlias
|
||||
|
||||
Macro Parameters To Create, for this macro to work:
|
||||
Alias:propertyAlias Name:Property Alias Type:Textbox
|
||||
*@
|
||||
*@
|
||||
|
||||
@{
|
||||
@* Get the property alias we want to filter on from the macro parameter *@
|
||||
var propertyAlias = Model.MacroParameters["propertyAlias"];
|
||||
@{ var propertyAlias = Model.MacroParameters["propertyAlias"]; }
|
||||
@if (propertyAlias != null)
|
||||
{
|
||||
var selection = CurrentPage.Children.Where("Visible").OrderBy(propertyAlias);
|
||||
}
|
||||
|
||||
<ul>
|
||||
@foreach (var page in selection)
|
||||
{
|
||||
<li><a href="@page.Url">@page.Name</a></li>
|
||||
}
|
||||
</ul>
|
||||
<ul>
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li><a href="@item.Url">@item.Name</a></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
@@ -1,30 +1,25 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@*
|
||||
This snippet shows how simple it is to fetch only children of a certain Document Type using Razor. Instead of
|
||||
calling .Children, simply call .AliasOfDocumentType in plural.
|
||||
For instance .Textpages or .NewsArticles (you can find the alias of your Document Type by editing it in the
|
||||
Settings section).
|
||||
This snippet shows how simple it is to fetch only children of a certain Document Type using Razor.
|
||||
Be sure to change "DocumentTypeAlias" below to match your needs, such as "TextPage" or "NewsItems".
|
||||
(You can find the alias of your Document Type by editing it in the Settings section)
|
||||
*@
|
||||
|
||||
@{
|
||||
@*Build a query and return the visible items *@
|
||||
var selection= CurrentPage.Textpages.Where("Visible");
|
||||
|
||||
@*
|
||||
Example of more querying, if you have a true/false property with the alias of shouldBeFeatured:
|
||||
var selection= Model.Textpages.Where("shouldBeFeatured == true").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>
|
||||
|
||||
@{ var selection = CurrentPage.Children("DocumentTypeAlias").Where("Visible"); }
|
||||
@*
|
||||
As an example of more querying, if you have a true/false property with the alias of shouldBeFeatured:
|
||||
var selection= CurrentPage.Children("DocumentTypeAlias").Where("shouldBeFeatured == true").Where("Visible");
|
||||
*@
|
||||
|
||||
|
||||
@if (selection.Any())
|
||||
{
|
||||
<ul>
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li><a href="@item.Url">@item.Name</a></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,31 @@
|
||||
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
|
||||
|
||||
@* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@
|
||||
@if (CurrentPage.Children.Where("Visible").Any())
|
||||
@*
|
||||
This snippet creates links for every single page (no matter how deep) below
|
||||
the page currently being viewed by the website visitor, displayed as nested unordered html lists.
|
||||
*@
|
||||
|
||||
@{ var selection = CurrentPage.Children.Where("Visible"); }
|
||||
|
||||
@* Ensure that the Current Page has children *@
|
||||
@if (selection.Any())
|
||||
{
|
||||
@* Get the first page in the children, where the property umbracoNaviHide is not True *@
|
||||
var naviLevel = CurrentPage.Children.Where("Visible").First().Level;
|
||||
|
||||
var naviLevel = CurrentPage.FirstChild().Where("Visible").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("Visible"))
|
||||
<ul class="level-@naviLevel">
|
||||
@* For each child page where the property umbracoNaviHide is not True *@
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li>
|
||||
<a href="@childPage.Url">@childPage.Name</a>
|
||||
<a href="@item.Url">@item.Name</a>
|
||||
|
||||
@* if the current page has any children, where the property umbracoNaviHide is not True *@
|
||||
@if (childPage.Children.Where("Visible").Any())
|
||||
{
|
||||
@* if this child page has any children, where the property umbracoNaviHide is not True *@
|
||||
@if (item.Children.Where("Visible").Any())
|
||||
{
|
||||
@* Call our helper to display the children *@
|
||||
@childPages(childPage.Children)
|
||||
@childPages(item.Children)
|
||||
}
|
||||
</li>
|
||||
}
|
||||
@@ -26,26 +33,26 @@
|
||||
}
|
||||
|
||||
|
||||
@helper childPages(dynamic pages)
|
||||
{
|
||||
@helper childPages(dynamic selection)
|
||||
{
|
||||
@* Ensure that we have a collection of pages *@
|
||||
if (pages.Any())
|
||||
if (selection.Any())
|
||||
{
|
||||
@* Get the first page in pages and get the level *@
|
||||
var naviLevel = pages.First().Level;
|
||||
|
||||
var naviLevel = selection.First().Level;
|
||||
|
||||
@* Add in level for a CSS hook *@
|
||||
<ul class="level-@(naviLevel)">
|
||||
@foreach (var page in pages.Where("Visible"))
|
||||
@foreach (var item in selection.Where("Visible"))
|
||||
{
|
||||
<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("Visible").Any())
|
||||
{
|
||||
<a href="@item.Url">@item.Name</a>
|
||||
|
||||
@* if the this page has any children, where the property umbracoNaviHide is not True *@
|
||||
@if (item.Children.Where("Visible").Any())
|
||||
{
|
||||
@* Call our helper to display the children *@
|
||||
@childPages(page.Children)
|
||||
@childPages(item.Children)
|
||||
}
|
||||
</li>
|
||||
}
|
||||
|
||||
@@ -1,23 +1,33 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@*
|
||||
Macro to display a series of images from a media folder.
|
||||
|
||||
How it works:
|
||||
- Confirm the macro parameter has been passed in with a value
|
||||
- Loop through all the media Id's passed in (might be a single item, might be many)
|
||||
- Display any individual images, as well as any folders of images
|
||||
|
||||
Macro Parameters To Create, for this macro to work:
|
||||
Alias:mediaId Name:Media Folder ID Type:Single Media Picker
|
||||
Alias:mediaId Name:Select folder with images Type:Single Media Picker
|
||||
*@
|
||||
|
||||
@if (Model.MacroParameters["mediaId"] != null)
|
||||
@{ var mediaId = Model.MacroParameters["mediaId"]; }
|
||||
@if (mediaId != null)
|
||||
{
|
||||
@* Get the media folder as a dynamic node *@
|
||||
var mediaFolder = Umbraco.Media(Model.MacroParameters["mediaId"]);
|
||||
|
||||
if (mediaFolder.Children.Any())
|
||||
@* Get all the media item associated with the id passed in *@
|
||||
var media = Umbraco.Media(mediaId);
|
||||
var selection = media.Children("Image");
|
||||
|
||||
if (selection.Any())
|
||||
{
|
||||
<ul>
|
||||
@* for each item in children of the selected media folder *@
|
||||
@foreach (var mediaItem in mediaFolder.Children)
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li><img src="@mediaItem.umbracoFile" alt="@mediaItem.Name" /></li>
|
||||
<li>
|
||||
<img src="@item.umbracoFile" alt="@item.Name" />
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@*
|
||||
Macro to list nodes from a Multinode tree picker, using the pickers default settings.
|
||||
Content Values stored as xml.
|
||||
This snippet lists the items from a Multinode tree picker, using the pickers default settings.
|
||||
Content Values stored as xml.
|
||||
|
||||
To get it working with any site's data structure, simply set the selection equal to the property which has the
|
||||
multinode treepicker (so: replace "PropertyWithPicker" with the alias of your property).
|
||||
To get it working with any site's data structure, set the selection equal to the property which has the
|
||||
multinode treepicker (so: replace "PropertyWithPicker" with the alias of your property).
|
||||
*@
|
||||
|
||||
@* Lists each selected value from the picker as a link *@
|
||||
@{ var selection = CurrentPage.PropertyWithPicker.Split(','); }
|
||||
|
||||
<ul>
|
||||
@foreach(var id in CurrentPage.PropertyWithPicker.Split(',')){
|
||||
|
||||
@*For each link, get the node, and display its name and url*@
|
||||
var content = Umbraco.Content(id);
|
||||
|
||||
<li><a href="@content.Url">@content.Name</a></li>
|
||||
}
|
||||
@foreach (var id in selection)
|
||||
{
|
||||
var item = Umbraco.Content(id);
|
||||
<li>
|
||||
<a href="@item.Url">@item.Name</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
@@ -1,21 +1,18 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@*
|
||||
Macro to display child pages below the root page of a standard website.
|
||||
Also highlights the current active page/section in the navigation with
|
||||
the css class "current".
|
||||
This snippet displays a list of links of the pages immediately under the top-most page in the content tree.
|
||||
This is the home page for a standard website.
|
||||
It also highlights the current active page/section in the navigation with the css class "current".
|
||||
*@
|
||||
|
||||
@{
|
||||
@* Get the root of the website *@
|
||||
var root = CurrentPage.AncestorOrSelf(1);
|
||||
}
|
||||
@{ var selection = CurrentPage.Site().Children.Where("Visible"); }
|
||||
|
||||
<ul>
|
||||
@foreach (var page in root.Children.Where("Visible"))
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li class="@(page.IsAncestorOrSelf(CurrentPage) ? "current" : null)">
|
||||
<a href="@page.Url">@page.Name</a>
|
||||
<li class="@(item.IsAncestorOrSelf(CurrentPage) ? "current" : null)">
|
||||
<a href="@item.Url">@item.Name</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
@@ -1,29 +1,39 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@* Render the sitemap by passing the root node to the traverse helper *@
|
||||
@*
|
||||
This snippet makes a list of links of all visible pages of the site, as nested unordered html lists.
|
||||
|
||||
How it works:
|
||||
- It uses a custom Razor helper called Traverse() to select and display the markup and links.
|
||||
*@
|
||||
|
||||
@{ var selection = CurrentPage.Site(); }
|
||||
|
||||
<div class="sitemap">
|
||||
@Traverse(CurrentPage.AncestorOrSelf())
|
||||
@* Render the sitemap by passing the root node to the traverse helper, below *@
|
||||
@Traverse(selection)
|
||||
</div>
|
||||
|
||||
|
||||
@* Helper method to travers through all descendants *@
|
||||
@helper Traverse(dynamic node)
|
||||
{
|
||||
@* Update the level to reflect how deep you want the sitemap to go *@
|
||||
var maxLevelForSitemap = 4;
|
||||
|
||||
|
||||
@* Select visible children *@
|
||||
var items = node.Children.Where("Visible").Where("Level <= " + maxLevelForSitemap);
|
||||
var selection = node.Children.Where("Visible").Where("Level <= " + maxLevelForSitemap);
|
||||
|
||||
@* If any items are returned, render a list *@
|
||||
if (items.Any())
|
||||
if (selection.Any())
|
||||
{
|
||||
<ul>
|
||||
@foreach (var item in items)
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li class="level-@item.Level">
|
||||
<a href="@item.Url">@item.Name</a>
|
||||
|
||||
@* Run the traverse helper again *@
|
||||
@* Run the traverse helper again for any child pages *@
|
||||
@Traverse(item)
|
||||
</li>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user