Migrating as many of the templates from Umbraco.Web.UI\Umbraco\PartialViewMacros\Templates
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
@using Umbraco.Core.Models.PublishedContent
|
||||
@using Umbraco.Web
|
||||
@using Umbraco.Core
|
||||
@using Umbraco.Core.Media
|
||||
@using Umbraco.Web.Composing
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@using Umbraco.Core.Composing
|
||||
@using Umbraco.Core.PropertyEditors.ValueConverters
|
||||
@using Umbraco.Web.Routing
|
||||
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
|
||||
@inject IPublishedContentQuery PublishedContentQuery
|
||||
@inject IVariationContextAccessor VariationContextAccessor
|
||||
@inject IPublishedUrlProvider PublishedUrlProvider
|
||||
@inject IFactory Factory
|
||||
@*
|
||||
Macro to display a gallery of images from the Media section.
|
||||
Works with either a 'Single Media Picker' or a 'Multiple Media Picker' macro parameter (see below).
|
||||
@@ -26,28 +30,30 @@
|
||||
<div class="row">
|
||||
@foreach (var mediaId in mediaIds.Split(','))
|
||||
{
|
||||
var media = Current.PublishedContentQuery.Media(mediaId);
|
||||
var media = PublishedContentQuery.Media(mediaId);
|
||||
|
||||
@* a single image *@
|
||||
if (media.IsDocumentType("Image"))
|
||||
{
|
||||
@Render(media)
|
||||
Render(media);
|
||||
}
|
||||
|
||||
@* a folder with images under it *@
|
||||
foreach (var image in media.Children(Current.VariationContextAccessor))
|
||||
foreach (var image in media.Children(VariationContextAccessor))
|
||||
{
|
||||
@Render(image)
|
||||
Render(image);
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@helper Render(IPublishedContent item)
|
||||
{
|
||||
<div class="col-xs-6 col-md-3">
|
||||
<a href="@item.Url()" class="thumbnail">
|
||||
<img src="@(item.GetCropUrl(Current.Factory.GetInstance<IImageUrlGenerator>(), width:200, height:200))" alt="@item.Name" />
|
||||
</a>
|
||||
</div>
|
||||
@{
|
||||
void Render(IPublishedContent item)
|
||||
{
|
||||
/*@<div class="col-xs-6 col-md-3">
|
||||
<a href="@item.Url(PublishedUrlProvider)" class="thumbnail">
|
||||
<img src="@(item.GetCropUrl(Factory.GetInstance<IImageUrlGenerator>(), width: 200, height: 200))" alt="@item.Name" />
|
||||
</a>
|
||||
</div>;*/
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
@using Umbraco.Core
|
||||
@using Umbraco.Web
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@using Umbraco.Web.Routing
|
||||
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
|
||||
@inject IPublishedUrlProvider PublishedUrlProvider
|
||||
@*
|
||||
This snippet makes a list of links to the of parents of the current page using an unordered HTML list.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
@* For each page in the ancestors collection which have been ordered by Level (so we start with the highest top node first) *@
|
||||
@foreach (var item in selection.OrderBy(x => x.Level))
|
||||
{
|
||||
<li><a href="@item.Url()">@item.Name</a> »</li>
|
||||
<li><a href="@item.Url(PublishedUrlProvider)">@item.Name</a> »</li>
|
||||
}
|
||||
|
||||
@* Display the current page as the last item in the list *@
|
||||
@@ -1,7 +1,11 @@
|
||||
@using Umbraco.Core
|
||||
@using Umbraco.Core.Models.PublishedContent
|
||||
@using Umbraco.Web
|
||||
@using Umbraco.Web.Composing
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@using Umbraco.Web.Routing
|
||||
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
|
||||
@inject IPublishedContentQuery PublishedContentQuery
|
||||
@inject IPublishedValueFallback PublishedValueFallback
|
||||
@inject IPublishedUrlProvider PublishedUrlProvider
|
||||
@*
|
||||
Macro to list all child pages under a specific page in the content tree.
|
||||
|
||||
@@ -19,15 +23,15 @@
|
||||
@if (startNodeId != null)
|
||||
{
|
||||
@* Get the starting page *@
|
||||
var startNode = Current.PublishedContentQuery.Content(startNodeId);
|
||||
var selection = startNode.Children.Where(x => x.IsVisible()).ToArray();
|
||||
var startNode = PublishedContentQuery.Content(startNodeId);
|
||||
var selection = startNode.Children.Where(x => x.IsVisible(PublishedValueFallback)).ToArray();
|
||||
|
||||
if (selection.Length > 0)
|
||||
{
|
||||
<ul>
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li><a href="@item.Url">@item.Name</a></li>
|
||||
<li><a href="@item.Url(PublishedUrlProvider)">@item.Name</a></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
@using Umbraco.Web
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@using Umbraco.Core
|
||||
@using Umbraco.Core.Models.PublishedContent
|
||||
@using Umbraco.Web.Routing
|
||||
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
|
||||
@inject IPublishedValueFallback PublishedValueFallback
|
||||
@inject IPublishedUrlProvider PublishedUrlProvider
|
||||
@*
|
||||
This snippet makes a list of links to the of children of the current page using an unordered HTML list.
|
||||
|
||||
@@ -9,7 +12,7 @@
|
||||
- It then generates links so the visitor can go to each page
|
||||
*@
|
||||
|
||||
@{ var selection = Model.Content.Children.Where(x => x.IsVisible()).ToArray(); }
|
||||
@{ var selection = Model.Content.Children.Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); }
|
||||
|
||||
@if (selection.Length > 0)
|
||||
{
|
||||
@@ -17,7 +20,7 @@
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li>
|
||||
<a href="@item.Url">@item.Name</a>
|
||||
<a href="@item.Url(PublishedUrlProvider)">@item.Name</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
@@ -1,6 +1,9 @@
|
||||
@using Umbraco.Web
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@using Umbraco.Core
|
||||
@using Umbraco.Core.Models.PublishedContent
|
||||
@using Umbraco.Web.Routing
|
||||
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
|
||||
@inject IPublishedValueFallback PublishedValueFallback
|
||||
@inject IPublishedUrlProvider PublishedUrlProvider
|
||||
@*
|
||||
This snippet makes a list of links to the of children of the current page using an unordered HTML list.
|
||||
|
||||
@@ -10,14 +13,14 @@
|
||||
- It then generates links so the visitor can go to each page
|
||||
*@
|
||||
|
||||
@{ var selection = Model.Content.Children.Where(x => x.IsVisible()).OrderByDescending(x => x.CreateDate).ToArray(); }
|
||||
@{ var selection = Model.Content.Children.Where(x => x.IsVisible(PublishedValueFallback)).OrderByDescending(x => x.CreateDate).ToArray(); }
|
||||
|
||||
@if (selection.Length > 0)
|
||||
{
|
||||
<ul>
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li><a href="@item.Url">@item.Name</a></li>
|
||||
<li><a href="@item.Url(PublishedUrlProvider)">@item.Name</a></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
@using Umbraco.Web
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@using Umbraco.Core
|
||||
@using Umbraco.Core.Models.PublishedContent
|
||||
@using Umbraco.Web.Routing
|
||||
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
|
||||
@inject IPublishedValueFallback PublishedValueFallback
|
||||
@inject IPublishedUrlProvider PublishedUrlProvider
|
||||
@*
|
||||
This snippet makes a list of links to the of children of the current page using an unordered HTML list.
|
||||
|
||||
@@ -10,14 +13,14 @@
|
||||
- It then generates links so the visitor can go to each page
|
||||
*@
|
||||
|
||||
@{ var selection = Model.Content.Children.Where(x => x.IsVisible()).OrderBy(x => x.Name).ToArray(); }
|
||||
@{ var selection = Model.Content.Children.Where(x => x.IsVisible(PublishedValueFallback)).OrderBy(x => x.Name).ToArray(); }
|
||||
|
||||
@if (selection.Length > 0)
|
||||
{
|
||||
<ul>
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li><a href="@item.Url">@item.Name</a></li>
|
||||
<li><a href="@item.Url(PublishedUrlProvider))">@item.Name</a></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
@using Umbraco.Core
|
||||
@using Umbraco.Core.Models.PublishedContent
|
||||
@using Umbraco.Web
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@using Umbraco.Web.Routing
|
||||
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
|
||||
@inject IPublishedValueFallback PublishedValueFallback
|
||||
@inject IPublishedUrlProvider PublishedUrlProvider
|
||||
@*
|
||||
Macro to list all child pages with a specific property, sorted by the value of that property.
|
||||
|
||||
@@ -17,14 +21,14 @@
|
||||
|
||||
@if (propertyAlias != null)
|
||||
{
|
||||
var selection = Model.Content.Children.Where(x => x.IsVisible()).OrderBy(x => x.Value(propertyAlias.ToString())).ToArray();
|
||||
var selection = Model.Content.Children.Where(x => x.IsVisible(PublishedValueFallback)).OrderBy(x => x.Value(PublishedValueFallback, propertyAlias.ToString())).ToArray();
|
||||
|
||||
if (selection.Length > 0)
|
||||
{
|
||||
<ul>
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li><a href="@item.Url">@item.Name</a></li>
|
||||
<li><a href="@item.Url(PublishedUrlProvider)">@item.Name</a></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
@using Umbraco.Core
|
||||
@using Umbraco.Core.Models.PublishedContent
|
||||
@using Umbraco.Web.Routing
|
||||
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
|
||||
@inject IVariationContextAccessor VariationContextAccessor
|
||||
@inject IPublishedValueFallback PublishedValueFallback
|
||||
@inject IPublishedUrlProvider PublishedUrlProvider
|
||||
@*
|
||||
This snippet shows how simple it is to fetch only children of a certain Document Type.
|
||||
|
||||
Be sure to change "IPublishedContent" below to match your needs, such as "TextPage" or "NewsItem".
|
||||
(You can find the alias of your Document Type by editing it in the Settings section)
|
||||
*@
|
||||
|
||||
@{ var selection = Model.Content.Children<IPublishedContent>(VariationContextAccessor).Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); }
|
||||
|
||||
@if (selection.Length > 0)
|
||||
{
|
||||
<ul>
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li><a href="@item.Url(PublishedUrlProvider)">@item.Name</a></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
@using Umbraco.Core
|
||||
@using Umbraco.Core.Models.PublishedContent
|
||||
@using Umbraco.Web.Routing
|
||||
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
|
||||
@inject IPublishedValueFallback PublishedValueFallback
|
||||
@inject IPublishedUrlProvider PublishedUrlProvider
|
||||
@*
|
||||
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 = Model.Content.Children.Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); }
|
||||
|
||||
@* Ensure that the Current Page has children *@
|
||||
@if (selection.Length > 0)
|
||||
{
|
||||
@* Get the first page in the children, where the property umbracoNaviHide is not True *@
|
||||
var naviLevel = selection[0].Level;
|
||||
|
||||
@* Add in level for a CSS hook *@
|
||||
<ul class="level-@(naviLevel)">
|
||||
@* Loop through the selection *@
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li>
|
||||
<a href="@item.Url(PublishedUrlProvider)">@item.Name</a>
|
||||
|
||||
@* if this child page has any children, where the property umbracoNaviHide is not True *@
|
||||
@{
|
||||
var children = item.Children.Where(x => x.IsVisible(PublishedValueFallback)).ToArray();
|
||||
if (children.Length > 0)
|
||||
{
|
||||
@* Call a local method to display the children *@
|
||||
ChildPages(children);
|
||||
}
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
@{
|
||||
void ChildPages(IPublishedContent[] selection)
|
||||
{
|
||||
//Ensure that we have a collection of pages
|
||||
if (selection.Length > 0)
|
||||
{
|
||||
// Get the first page in pages and get the level
|
||||
var naviLevel = selection[0].Level;
|
||||
|
||||
// Add in level for a CSS hook
|
||||
<ul class="level-@(naviLevel)">
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li>
|
||||
<a href="@item.Url(PublishedUrlProvider)">@item.Name</a>
|
||||
|
||||
@* if the page has any children, where the property umbracoNaviHide is not True *@
|
||||
@{
|
||||
var children = item.Children.Where(x => x.IsVisible(PublishedValueFallback)).ToArray();
|
||||
if (children.Length > 0)
|
||||
{
|
||||
@* Recurse and call the ChildPages method to display the children *@
|
||||
ChildPages(children);
|
||||
}
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
@using Umbraco.Core
|
||||
@using Umbraco.Web
|
||||
@using Umbraco.Web.Composing
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@using Umbraco.Web.Routing
|
||||
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
|
||||
@inject IPublishedContentQuery PublishedContentQuery
|
||||
@inject IPublishedUrlProvider PublishedUrlProvider
|
||||
@*
|
||||
Macro to display a series of images from a media folder.
|
||||
|
||||
@@ -19,7 +21,7 @@
|
||||
@if (mediaId != null)
|
||||
{
|
||||
@* Get the media item associated with the id passed in *@
|
||||
var media = Current.PublishedContentQuery.Media(mediaId);
|
||||
var media = PublishedContentQuery.Media(mediaId);
|
||||
var selection = media.Children.ToArray();
|
||||
|
||||
if (selection.Length > 0)
|
||||
@@ -28,7 +30,7 @@
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li>
|
||||
<img src="@item.Url()" alt="@item.Name" />
|
||||
<img src="@item.Url(PublishedUrlProvider)" alt="@item.Name" />
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
@@ -1,7 +1,9 @@
|
||||
@using Umbraco.Core
|
||||
@using Umbraco.Core.Models.PublishedContent
|
||||
@using Umbraco.Web
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@using Umbraco.Web.Routing
|
||||
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
|
||||
@inject IPublishedValueFallback PublishedValueFallback
|
||||
@inject IPublishedUrlProvider PublishedUrlProvider
|
||||
@*
|
||||
This snippet lists the items from a Multinode tree picker, using the picker's default settings.
|
||||
Content Values stored as XML.
|
||||
@@ -10,7 +12,7 @@
|
||||
multinode treepicker (so: replace "PropertyWithPicker" with the alias of your property).
|
||||
*@
|
||||
|
||||
@{ var selection = Model.Content.Value<IEnumerable<IPublishedContent>>("PropertyWithPicker").ToArray(); }
|
||||
@{ var selection = Model.Content.Value<IEnumerable<IPublishedContent>>(PublishedValueFallback, "PropertyWithPicker").ToArray(); }
|
||||
|
||||
@if (selection.Length > 0)
|
||||
{
|
||||
@@ -18,7 +20,7 @@
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li>
|
||||
<a href="@item.Url">@item.Name</a>
|
||||
<a href="@item.Url(PublishedUrlProvider)">@item.Name</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
@@ -1,14 +1,16 @@
|
||||
@using Umbraco.Core
|
||||
@using Umbraco.Web
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@using Umbraco.Core.Models.PublishedContent
|
||||
@using Umbraco.Web.Routing
|
||||
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
|
||||
@inject IPublishedValueFallback PublishedValueFallback
|
||||
@inject IPublishedUrlProvider PublishedUrlProvider
|
||||
@*
|
||||
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".
|
||||
*@
|
||||
|
||||
@{ var selection = Model.Content.Root().Children.Where(x => x.IsVisible()).ToArray(); }
|
||||
@{ var selection = Model.Content.Root().Children.Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); }
|
||||
|
||||
@if (selection.Length > 0)
|
||||
{
|
||||
@@ -16,7 +18,7 @@
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li class="@(item.IsAncestorOrSelf(Model.Content) ? "current" : null)">
|
||||
<a href="@item.Url()">@item.Name</a>
|
||||
<a href="@item.Url(PublishedUrlProvider)">@item.Name</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
@@ -0,0 +1,47 @@
|
||||
@using Umbraco.Core
|
||||
@using Umbraco.Core.Models.PublishedContent
|
||||
@using Umbraco.Web.Routing
|
||||
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
|
||||
@inject IPublishedValueFallback PublishedValueFallback
|
||||
@inject IPublishedUrlProvider PublishedUrlProvider
|
||||
@*
|
||||
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 local method called Traverse() to select and display the markup and links.
|
||||
*@
|
||||
|
||||
@{ var selection = Model.Content.Root(); }
|
||||
|
||||
<div class="sitemap">
|
||||
@* Render the sitemap by passing the root node to the traverse method, below *@
|
||||
@{ Traverse(selection); }
|
||||
</div>
|
||||
|
||||
@* Helper method to traverse through all descendants *@
|
||||
@{
|
||||
void Traverse(IPublishedContent node)
|
||||
{
|
||||
//Update the level to reflect how deep you want the sitemap to go
|
||||
const int maxLevelForSitemap = 4;
|
||||
|
||||
@* Select visible children *@
|
||||
var selection = node.Children.Where(x => x.IsVisible(PublishedValueFallback) && x.Level <= maxLevelForSitemap).ToArray();
|
||||
|
||||
@* If any items are returned, render a list *@
|
||||
if (selection.Length > 0)
|
||||
{
|
||||
<ul>
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li class="level-@item.Level">
|
||||
<a href="@item.Url(PublishedUrlProvider)">@item.Name</a>
|
||||
|
||||
@* Run the traverse method again for any child pages *@
|
||||
@{ Traverse(item); }
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,46 +190,6 @@
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\Gallery.cshtml">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\ListAncestorsFromCurrentPage.cshtml">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\ListChildPagesFromChangeableSource.cshtml">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\ListChildPagesFromCurrentPage.cshtml">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\ListChildPagesOrderedByDate.cshtml">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\ListChildPagesOrderedByName.cshtml">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\ListChildPagesOrderedByProperty.cshtml">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\ListChildPagesWithDoctype.cshtml">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\ListDescendantsFromCurrentPage.cshtml">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\ListImagesFromMediaFolder.cshtml">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\Login.cshtml">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
@@ -238,22 +198,10 @@
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\MultinodeTree-picker.cshtml">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\Navigation.cshtml">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\RegisterMember.cshtml">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\SiteMap.cshtml">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Umbraco\Views\Default.cshtml" />
|
||||
<Content Include="Umbraco\Views\AuthorizeUpgrade.cshtml" />
|
||||
<Content Include="Views\Web.config">
|
||||
@@ -409,4 +357,4 @@
|
||||
<Message Text="ConfigFile: $(OriginalFileName) -> $(OutputFileName)" Importance="high" Condition="Exists('$(ModifiedFileName)')" />
|
||||
<Copy SourceFiles="$(ModifiedFileName)" DestinationFiles="$(OutputFileName)" OverwriteReadOnlyFiles="true" SkipUnchangedFiles="false" Condition="Exists('$(ModifiedFileName)')" />
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -1,22 +0,0 @@
|
||||
@using Umbraco.Core.Models.PublishedContent
|
||||
@using Umbraco.Web
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@*
|
||||
This snippet shows how simple it is to fetch only children of a certain Document Type.
|
||||
|
||||
Be sure to change "IPublishedContent" below to match your needs, such as "TextPage" or "NewsItem".
|
||||
(You can find the alias of your Document Type by editing it in the Settings section)
|
||||
*@
|
||||
|
||||
@{ var selection = Model.Content.Children<IPublishedContent>().Where(x => x.IsVisible()).ToArray(); }
|
||||
|
||||
@if (selection.Length > 0)
|
||||
{
|
||||
<ul>
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li><a href="@item.Url">@item.Name</a></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
@using Umbraco.Core.Models.PublishedContent
|
||||
@using Umbraco.Web
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@*
|
||||
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 = Model.Content.Children.Where(x => x.IsVisible()).ToArray(); }
|
||||
|
||||
@* Ensure that the Current Page has children *@
|
||||
@if (selection.Length > 0)
|
||||
{
|
||||
@* Get the first page in the children, where the property umbracoNaviHide is not True *@
|
||||
var naviLevel = selection[0].Level;
|
||||
|
||||
@* Add in level for a CSS hook *@
|
||||
<ul class="level-@(naviLevel)">
|
||||
@* Loop through the selection *@
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li>
|
||||
<a href="@item.Url">@item.Name</a>
|
||||
|
||||
@* if this child page has any children, where the property umbracoNaviHide is not True *@
|
||||
@{
|
||||
var children = item.Children.Where(x => x.IsVisible()).ToArray();
|
||||
if (children.Length > 0)
|
||||
{
|
||||
@* Call our helper to display the children *@
|
||||
@ChildPages(children)
|
||||
}
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
@helper ChildPages(IPublishedContent[] selection)
|
||||
{
|
||||
@* Ensure that we have a collection of pages *@
|
||||
if (selection.Length > 0)
|
||||
{
|
||||
@* Get the first page in pages and get the level *@
|
||||
var naviLevel = selection[0].Level;
|
||||
|
||||
@* Add in level for a CSS hook *@
|
||||
<ul class="level-@(naviLevel)">
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li>
|
||||
<a href="@item.Url">@item.Name</a>
|
||||
|
||||
@* if the page has any children, where the property umbracoNaviHide is not True *@
|
||||
@{
|
||||
var children = item.Children.Where(x => x.IsVisible()).ToArray();
|
||||
if (children.Length > 0)
|
||||
{
|
||||
@* Recurse and call our helper to display the children *@
|
||||
@ChildPages(children)
|
||||
}
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
@using Umbraco.Core
|
||||
@using Umbraco.Core.Models.PublishedContent
|
||||
@using Umbraco.Web
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@*
|
||||
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 = Model.Content.Root(); }
|
||||
|
||||
<div class="sitemap">
|
||||
@* Render the sitemap by passing the root node to the traverse helper, below *@
|
||||
@Traverse(selection)
|
||||
</div>
|
||||
|
||||
@* Helper method to traverse through all descendants *@
|
||||
@helper Traverse(IPublishedContent node)
|
||||
{
|
||||
@* Update the level to reflect how deep you want the sitemap to go *@
|
||||
const int maxLevelForSitemap = 4;
|
||||
|
||||
@* Select visible children *@
|
||||
var selection = node.Children.Where(x => x.IsVisible() && x.Level <= maxLevelForSitemap).ToArray();
|
||||
|
||||
@* If any items are returned, render a list *@
|
||||
if (selection.Length > 0)
|
||||
{
|
||||
<ul>
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li class="level-@item.Level">
|
||||
<a href="@item.Url()">@item.Name</a>
|
||||
|
||||
@* Run the traverse helper again for any child pages *@
|
||||
@Traverse(item)
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user