Add WebCms

This commit is contained in:
2016-11-07 12:56:17 -05:00
parent dfe92218f4
commit 15911f33c0
2750 changed files with 365672 additions and 133 deletions
@@ -0,0 +1,24 @@
@inherits umbraco.MacroEngines.DynamicNodeContext
@*
This snippet makes a breadcrumb of parents using an unordred html list.
How it works:
- It uses the Ancestors() method to get all parents and then generates links so the visitor get go back
- Finally it outputs the name of the current page (without a link)
*@
@if (Model.Ancestors().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 Model.Ancestors().OrderBy("Level"))
{
<li><a href="@page.Url">@page.Name</a> <span class="divider">/</span></li>
}
@* Display the current page as the last item in the list *@
<li class="active">@Model.Name</li>
</ul>
}
@@ -0,0 +1,15 @@
@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
Library = utillity library with common methods
@Library.NodeById(1233)
*@
@* The fun starts here *@
@@ -0,0 +1,32 @@
@inherits umbraco.MacroEngines.DynamicNodeContext
@*
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 Parameters To Create, for this macro to work:
Alias:mediaId Name:Media Folder ID Type:Single Media Picker
*@
@if (Parameter.mediaId != null)
{
@* Get the media folder as a dynamic node *@
var mediaFolder = Library.MediaById(Parameter.mediaId);
if (mediaFolder.Children.Any())
{
<ul class="thumbnails">
@* for each item in children of the selected media folder *@
@foreach (var mediaItem in mediaFolder.Children)
{
<li class="span2">
<a href="@mediaItem.umbracoFile" class="thumbnail">
<img src="@mediaItem.umbracoFile" alt="@mediaItem.Name" />
</a>
</li>
}
</ul>
}
}
@@ -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> &raquo;</li>
}
@* Display the current page as the last item in the list *@
<li>@Model.Name</li>
</ul>
}
@@ -0,0 +1,26 @@
@inherits umbraco.MacroEngines.DynamicNodeContext
@*
=== Macro Parameters To Create ===
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>
}
}
@@ -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>
}
@@ -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>
@@ -0,0 +1,9 @@
@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>
@@ -0,0 +1,20 @@
@inherits umbraco.MacroEngines.DynamicNodeContext
@*
Macro parameter to be set on the macro
Alias:propertyAlias Name:Property Alias Type:Textbox
*@
@{
@* 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>
@@ -0,0 +1,30 @@
@inherits umbraco.MacroEngines.DynamicNodeContext
@*
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).
*@
@{
@* Build a query and return the visible items *@
var selection= Model.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>
}
@@ -0,0 +1,54 @@
@inherits umbraco.MacroEngines.DynamicNodeContext
@* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@
@if (Model.Children.Where("Visible").Any())
{
@* Get the first page in the children, where the property umbracoNaviHide is not True *@
var naviLevel = Model.Children.Where("Visible").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 Model.Children.Where("Visible"))
{
<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("Visible").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("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())
{
@* Call our helper to display the children *@
@childPages(page.Children)
}
</li>
}
</ul>
}
}
@@ -0,0 +1,23 @@
@inherits umbraco.MacroEngines.DynamicNodeContext
@*
Macro Parameters To Create, for this macro to work:
Alias:mediaId Name:Media Folder ID Type:Single Media Picker
*@
@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>
}
}
@@ -0,0 +1,24 @@
@inherits umbraco.MacroEngines.DynamicNodeContext
@*
Macro to list nodes 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.
*@
@{
var selection = Model.PropertyWithPicker;
}
@* Lists each selected value from the picker as a link *@
<ul>
@foreach(var id in selection.Split(',')){
@*For each link, get the node, and display its name and url*@
var node = Library.NodeById(id);
<li><a href="@node.Url">@node.Name</a></li>
}
</ul>
@@ -0,0 +1,21 @@
@inherits umbraco.MacroEngines.DynamicNodeContext
@*
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".
*@
@{
@* Get the root of the website *@
var root = Model.AncestorOrSelf(1);
}
<ul>
@foreach (var page in root.Children.Where("Visible"))
{
<li class="@page.IsAncestorOrSelf(Model, "current", "")">
<a href="@page.Url">@page.Name</a>
</li>
}
</ul>
@@ -0,0 +1,34 @@
@inherits umbraco.MacroEngines.DynamicNodeContext
@* Render the sitemap by passing the root node to the traverse helper *@
<div class="sitemap">
@traverse(@Model.AncestorOrSelf())
</div>
@* Helper method to travers through all descendants *@
@helper traverse(dynamic node)
{
@* If a MaxLevelForSitemap parameter is passed to the macro, otherwise default to 4 levels *@
var maxLevelForSitemap = String.IsNullOrEmpty(Parameter.MaxLevelForSitemap) ? 4 : int.Parse(Parameter.MaxLevelForSitemap);
@* Select visible children *@
var items = node.Children.Where("Visible").Where("Level <= " + maxLevelForSitemap);
@* If any items are returned, render a list *@
if (items.Any())
{
<ul>
@foreach (var item in items)
{
<li class="level-@item.Level">
<a href="@item.Url">@item.Name</a>
@*Run the traverse helper again *@
@traverse(item)
</li>
}
</ul>
}
}