Our.Umbraco.SimpleTreeMenu
1.0.0
Typed Treemenu for Umbraco
See the version list below for details.
Install-Package Our.Umbraco.SimpleTreeMenu -Version 1.0.0
dotnet add package Our.Umbraco.SimpleTreeMenu --version 1.0.0
<PackageReference Include="Our.Umbraco.SimpleTreeMenu" Version="1.0.0" />
paket add Our.Umbraco.SimpleTreeMenu --version 1.0.0
Our.Umbraco.SimpleTreeMenu
A simple treemenu propertyeditor that uses a doc-type (element) for menu items.
With a valueconverter that utilize the built in nestedcontent for type conversion of menu items.
Every item can be cast to an IPublishedElement for propertyaccess through Umbracos extension-methods.
It will work without the valueconverter, just remove the binary and use JObject instead of IEnumerable<ISimpleTreeItem>
Example:
@{
var navigationModel = Model.Value<IEnumerable<ISimpleTreeItem>>("navigation", defaultValue: new List<ISimpleTreeItem>());
@:<ul>
foreach (var item in navigationModel)
{
var element = (IPublishedElement)item;
var url = element.Value<IPublishedContent>("linkedContent")?.Url ?? element.Value<string>("linkedUrl") ?? "#";
@:<li><a class="nav-link" href="@url">@(element.Value<string>("title"))</a></li>
if (item.Children.Any())
{
@:<ul>
foreach (var child in item.Children)
{
var cElement = (IPublishedElement)child;
var cUrl = cElement.Value<IPublishedContent>("linkedContent")?.Url ?? cElement.Value<string>("linkedUrl") ?? "#";
@:<li><a class="nav-link" href="@cUrl">@(cElement.Value<string>("title"))</a></li>
}
@:</ul>
}
}
@:</ul>
}
Our.Umbraco.SimpleTreeMenu
A simple treemenu propertyeditor that uses a doc-type (element) for menu items.
With a valueconverter that utilize the built in nestedcontent for type conversion of menu items.
Every item can be cast to an IPublishedElement for propertyaccess through Umbracos extension-methods.
It will work without the valueconverter, just remove the binary and use JObject instead of IEnumerable<ISimpleTreeItem>
Example:
@{
var navigationModel = Model.Value<IEnumerable<ISimpleTreeItem>>("navigation", defaultValue: new List<ISimpleTreeItem>());
@:<ul>
foreach (var item in navigationModel)
{
var element = (IPublishedElement)item;
var url = element.Value<IPublishedContent>("linkedContent")?.Url ?? element.Value<string>("linkedUrl") ?? "#";
@:<li><a class="nav-link" href="@url">@(element.Value<string>("title"))</a></li>
if (item.Children.Any())
{
@:<ul>
foreach (var child in item.Children)
{
var cElement = (IPublishedElement)child;
var cUrl = cElement.Value<IPublishedContent>("linkedContent")?.Url ?? cElement.Value<string>("linkedUrl") ?? "#";
@:<li><a class="nav-link" href="@cUrl">@(cElement.Value<string>("title"))</a></li>
}
@:</ul>
}
}
@:</ul>
}
Release Notes
- 1.0 Release.
- Added interpolation-template item names = {{PROP}}. Defaults: {{$id}}, {{$key}}, {{$type}}, {{$level}}, {{$index}}
Dependencies
-
.NETFramework 4.7.2
- UmbracoCMS.Core (>= 8.1.0)
Used By
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.