Merge remote-tracking branch 'origin/netcore/netcore' into netcore/feature/AB7446-ModelsBuilderEmbedded-migration

This commit is contained in:
Elitsa Marinovska
2020-07-13 13:44:04 +02:00
67 changed files with 445 additions and 939 deletions

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<language>
</language>

View File

@@ -4,6 +4,11 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>Umbraco.Web.UI.NetCore</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DocumentationFile>bin\Release\Umbraco.Web.UI.NetCore.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Umbraco.Examine.Lucene\Umbraco.Examine.Lucene.csproj" />
<ProjectReference Include="..\Umbraco.ModelsBuilder.Embedded\Umbraco.ModelsBuilder.Embedded.csproj" />
@@ -87,42 +92,4 @@
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<Content Remove="Config\serilog.Release.config" />
<Content Remove="Config\serilog.user.Release.config" />
</ItemGroup>
<ItemGroup>
<None Remove="Config\logviewer.searches.config.js" />
</ItemGroup>
<ItemGroup>
<Content Include="Config\grid.editors.config.js" />
<Content Include="Config\logviewer.searches.config.js" />
</ItemGroup>
<ItemGroup>
<None Include="Config\serilog.Release.config">
<SubType>Designer</SubType>
<DependentUpon>serilog.config</DependentUpon>
</None>
<None Include="Config\serilog.user.Release.config">
<SubType>Designer</SubType>
<DependentUpon>serilog.user.config</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<Content Update="Config\serilog.config">
<SubType>Designer</SubType>
</Content>
<Content Update="Config\serilog.user.config">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="Umbraco\PartialViewMacros\Templates\Empty.cshtml" />
</ItemGroup>
</Project>

View File

@@ -1,63 +0,0 @@
@using System.Web.Mvc.Html
@using Umbraco.Web
@using Umbraco.Web.Composing
@using Umbraco.Web.Controllers
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
@{
var profileModel = Current.MembershipHelper.GetCurrentMemberProfileModel();
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
var success = TempData["ProfileUpdateSuccess"] != null;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validation-unobtrusive/3.2.11/jquery.validate.unobtrusive.min.js"></script>
@if (Current.MembershipHelper.IsLoggedIn() && profileModel != null)
{
if (success)
{
@* This message will show if profileModel.RedirectUrl is not defined (default) *@
<p>Profile updated</p>
}
using (Html.BeginUmbracoForm<UmbProfileController>("HandleUpdateProfile"))
{
<fieldset>
<legend>Edit profile</legend>
@Html.ValidationSummary("profileModel", true)
@Html.LabelFor(m => profileModel.Name)
@Html.TextBoxFor(m => profileModel.Name)
@Html.ValidationMessageFor(m => profileModel.Name)
<br />
@Html.LabelFor(m => profileModel.Email)
@Html.TextBoxFor(m => profileModel.Email)
@Html.ValidationMessageFor(m => profileModel.Email)
<br />
@for (var i = 0; i < profileModel.MemberProperties.Count; i++)
{
@Html.LabelFor(m => profileModel.MemberProperties[i].Value, profileModel.MemberProperties[i].Name)
@*
By default this will render a textbox but if you want to change the editor template for this property you can
easily change it. For example, if you wanted to render a custom editor for this field called "MyEditor" you would
create a file at ~/Views/Shared/EditorTemplates/MyEditor.cshtml", then you will change the next line of code to
render your specific editor template like:
@Html.EditorFor(m => profileModel.MemberProperties[i].Value, "MyEditor")
*@
@Html.EditorFor(m => profileModel.MemberProperties[i].Value)
@Html.HiddenFor(m => profileModel.MemberProperties[i].Alias)
<br />
}
<button>Save</button>
</fieldset>
}
}

View File

@@ -1,53 +0,0 @@
@using Umbraco.Core.Models.PublishedContent
@using Umbraco.Web
@using Umbraco.Core
@using Umbraco.Core.Media
@using Umbraco.Web.Composing
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
@*
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).
How it works:
- Confirm the macro parameter has been passed in with a value
- Loop through all the media Ids 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)
*@
@{ var mediaIds = Model.MacroParameters["mediaIds"] as string; }
@if (mediaIds != null)
{
<div class="row">
@foreach (var mediaId in mediaIds.Split(','))
{
var media = Current.PublishedContentQuery.Media(mediaId);
@* a single image *@
if (media.IsDocumentType("Image"))
{
@Render(media)
}
@* a folder with images under it *@
foreach (var image in media.Children(Current.VariationContextAccessor))
{
@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>
}

View File

@@ -1,27 +0,0 @@
@using Umbraco.Core
@using Umbraco.Web
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
@*
This snippet makes a list of links to the of parents of the current page using an unordered HTML list.
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 = Model.Content.Ancestors().ToArray(); }
@if (selection.Length > 0)
{
<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 item in selection.OrderBy(x => x.Level))
{
<li><a href="@item.Url()">@item.Name</a> &raquo;</li>
}
@* Display the current page as the last item in the list *@
<li>@Model.Content.Name</li>
</ul>
}

View File

@@ -1,34 +0,0 @@
@using Umbraco.Web
@using Umbraco.Web.Composing
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
@*
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
*@
@{ var startNodeId = Model.MacroParameters["startNodeId"]; }
@if (startNodeId != null)
{
@* Get the starting page *@
var startNode = Current.PublishedContentQuery.Content(startNodeId);
var selection = startNode.Children.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>
}
}

View File

@@ -1,24 +0,0 @@
@using Umbraco.Web
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
@*
This snippet makes a list of links to the of children of the current page using an unordered HTML list.
How it works:
- It uses the Children method to get all child pages
- It then generates links so the visitor can go to each page
*@
@{ var selection = Model.Content.Children.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>
}

View File

@@ -1,23 +0,0 @@
@using Umbraco.Web
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
@*
This snippet makes a list of links to the of children of the current page using an unordered HTML list.
How it works:
- It uses the Children method to get all child pages
- It then uses the OrderByDescending() method, which takes the property to sort. In this case the page's creation date.
- 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(); }
@if (selection.Length > 0)
{
<ul>
@foreach (var item in selection)
{
<li><a href="@item.Url">@item.Name</a></li>
}
</ul>
}

View File

@@ -1,23 +0,0 @@
@using Umbraco.Web
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
@*
This snippet makes a list of links to the of children of the current page using an unordered HTML list.
How it works:
- It uses the Children method to get all child pages
- It then uses the OrderBy() method, which takes the property to sort. In this case, the page's name.
- 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(); }
@if (selection.Length > 0)
{
<ul>
@foreach (var item in selection)
{
<li><a href="@item.Url">@item.Name</a></li>
}
</ul>
}

View File

@@ -1,31 +0,0 @@
@using Umbraco.Web
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
@*
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
*@
@{ var propertyAlias = Model.MacroParameters["propertyAlias"]; }
@if (propertyAlias != null)
{
var selection = Model.Content.Children.Where(x => x.IsVisible()).OrderBy(x => x.Value(propertyAlias.ToString())).ToArray();
if (selection.Length > 0)
{
<ul>
@foreach (var item in selection)
{
<li><a href="@item.Url">@item.Name</a></li>
}
</ul>
}
}

View File

@@ -1,22 +0,0 @@
@using Umbraco.Core.Models.PublishedContent
@using Umbraco.Web
@inherits Umbraco.Web.Common.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>
}

View File

@@ -1,68 +0,0 @@
@using Umbraco.Core.Models.PublishedContent
@using Umbraco.Web
@inherits Umbraco.Web.Common.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>
}
}

View File

@@ -1,36 +0,0 @@
@using Umbraco.Web
@using Umbraco.Web.Composing
@inherits Umbraco.Web.Common.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 Ids 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:Select folder with images Type:Single Media Picker
*@
@{ var mediaId = Model.MacroParameters["mediaId"]; }
@if (mediaId != null)
{
@* Get the media item associated with the id passed in *@
var media = Current.PublishedContentQuery.Media(mediaId);
var selection = media.Children.ToArray();
if (selection.Length > 0)
{
<ul>
@foreach (var item in selection)
{
<li>
<img src="@item.Url()" alt="@item.Name" />
</li>
}
</ul>
}
}

View File

@@ -1,41 +0,0 @@
@using System.Web.Mvc.Html
@using Umbraco.Web
@using Umbraco.Web.Composing
@using Umbraco.Web.Models
@using Umbraco.Web.Controllers
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
@{
var loginModel = new LoginModel();
loginModel.RedirectUrl = HttpContext.Current.Request.Url.AbsolutePath;
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validation-unobtrusive/3.2.11/jquery.validate.unobtrusive.min.js"></script>
@using (Html.BeginUmbracoForm<UmbLoginController>("HandleLogin"))
{
@Html.HiddenFor(m => loginModel.RedirectUrl)
<fieldset>
<legend>Login</legend>
@Html.ValidationSummary("loginModel", true)
@Html.LabelFor(m => loginModel.Username)
@Html.TextBoxFor(m => loginModel.Username)
@Html.ValidationMessageFor(m => loginModel.Username)
<br />
@Html.LabelFor(m => loginModel.Password)
@Html.PasswordFor(m => loginModel.Password)
@Html.ValidationMessageFor(m => loginModel.Password)
<br />
<button>Login</button>
</fieldset>
}

View File

@@ -1,33 +0,0 @@
@using System.Web.Mvc.Html
@using Umbraco.Web
@using Umbraco.Web.Composing
@using Umbraco.Web.Models
@using Umbraco.Web.Controllers
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
@{
var loginStatusModel = Current.MembershipHelper.GetCurrentLoginStatus();
var logoutModel = new PostRedirectModel();
@*
Here you can specify a redirect URL for after logging out, by default umbraco will simply
redirect to the current page. Example to redirect to the home page:
logoutModel.RedirectUrl = "/";
*@
}
@if (loginStatusModel.IsLoggedIn)
{
<p>You are currently logged in as @loginStatusModel.Name</p>
using (Html.BeginUmbracoForm<UmbLoginStatusController>("HandleLogout"))
{
<fieldset>
<legend>Logout</legend>
<button>Logout</button>
</fieldset>
@Html.HiddenFor(m => logoutModel.RedirectUrl)
}
}

View File

@@ -1,25 +0,0 @@
@using Umbraco.Core.Models.PublishedContent
@using Umbraco.Web
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
@*
This snippet lists the items from a Multinode tree picker, using the picker's default settings.
Content Values stored as XML.
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).
*@
@{ var selection = Model.Content.Value<IEnumerable<IPublishedContent>>("PropertyWithPicker").ToArray(); }
@if (selection.Length > 0)
{
<ul>
@foreach (var item in selection)
{
<li>
<a href="@item.Url">@item.Name</a>
</li>
}
</ul>
}

View File

@@ -1,23 +0,0 @@
@using Umbraco.Core
@using Umbraco.Web
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
@*
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(); }
@if (selection.Length > 0)
{
<ul>
@foreach (var item in selection)
{
<li class="@(item.IsAncestorOrSelf(Model.Content) ? "current" : null)">
<a href="@item.Url()">@item.Name</a>
</li>
}
</ul>
}

View File

@@ -1,101 +0,0 @@
@using System.Web.Mvc.Html
@using Umbraco.Web
@using Umbraco.Web.Composing
@using Umbraco.Web.Controllers
@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage
@{
@*
You can specify a custom member type alias in the constructor, the default is 'Member'
for example, to use 'Custom Member' you'd use this syntax:
var registerModel = Members.CreateRegistrationModel("Custom Member");
*@
var registerModel = Current.MembershipHelper.CreateRegistrationModel();
@*
Configurable here:
registerModel.RedirectUrl - Optional. What path to redirect to if registration is successful.
By default the member will be redirected to the current umbraco page
unless this is specified.
registerModel.UsernameIsEmail - the default is true
if you want the username to be different from the email
address, set this to true and add a new Username field in
the form below
@Html.LabelFor(m => registerModel.Username)
@Html.TextBoxFor(m => registerModel.Username)
@Html.ValidationMessageFor(m => registerModel.Username)
*@
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
var success = TempData["FormSuccess"] != null;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validation-unobtrusive/3.2.11/jquery.validate.unobtrusive.min.js"></script>
@if (success)
{
@* This message will show if registerModel.RedirectUrl is not defined (default) *@
<p>Registration succeeded.</p>
}
else
{
using (Html.BeginUmbracoForm<UmbRegisterController>("HandleRegisterMember"))
{
<fieldset>
<legend>Register Member</legend>
@Html.ValidationSummary("registerModel", true)
@Html.LabelFor(m => registerModel.Name)
@Html.TextBoxFor(m => registerModel.Name)
@Html.ValidationMessageFor(m => registerModel.Name)
<br />
@Html.LabelFor(m => registerModel.Email)
@Html.TextBoxFor(m => registerModel.Email)
@Html.ValidationMessageFor(m => registerModel.Email)
<br />
@Html.LabelFor(m => registerModel.Password)
@Html.PasswordFor(m => registerModel.Password)
@Html.ValidationMessageFor(m => registerModel.Password)
<br />
@if (registerModel.MemberProperties != null)
{
@*
It will only displays properties marked as "Member can edit" on the "Info" tab of the Member Type.
*@
for (var i = 0; i < registerModel.MemberProperties.Count; i++)
{
@Html.LabelFor(m => registerModel.MemberProperties[i].Value, registerModel.MemberProperties[i].Name)
@*
By default this will render a textbox but if you want to change the editor template for this property you can
easily change it. For example, if you wanted to render a custom editor for this field called "MyEditor" you would
create a file at ~/Views/Shared/EditorTemplates/MyEditor.cshtml", then you will change the next line of code to
render your specific editor template like:
@Html.EditorFor(m => registerModel.MemberProperties[i].Value, "MyEditor")
*@
@Html.EditorFor(m => registerModel.MemberProperties[i].Value)
@Html.HiddenFor(m => registerModel.MemberProperties[i].Alias)
<br />
}
}
@Html.HiddenFor(m => registerModel.MemberTypeAlias)
@Html.HiddenFor(m => registerModel.RedirectUrl)
@Html.HiddenFor(m => registerModel.UsernameIsEmail)
<button>Register</button>
</fieldset>
}
}

View File

@@ -1,44 +0,0 @@
@using Umbraco.Core
@using Umbraco.Core.Models.PublishedContent
@using Umbraco.Web
@inherits Umbraco.Web.Common.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>
}
}

View File

@@ -1,6 +1,4 @@
@using Umbraco.Core
@using Umbraco.Web.Composing
@using Umbraco.Web
@using Umbraco.Web.WebAssets
@using Umbraco.Web.Common.Security
@using Umbraco.Core.WebAssets