4 votes

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 href="@url">@(element.Value<string>("title"))</a></li>

if (item.Children.Any())
{
@:<ul>
foreach (var child in item.Children)
{
var cElement = (IPublishedElement)child;
@:<li>@(cElement.Value<string>("title"))</li>
}
@:</ul>
}
}

@:</ul>

Screenshots

Package owner

Dennis Öhman

Dennis Öhman

Dennis has 115 karma points

Package Compatibility

This package is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
8.3.x (100%)
8.2.x (100%)
8.1.x (100%)
8.0.x (untested)
7.15.x (untested)
7.14.x (untested)
7.13.x (untested)
7.12.x (untested)
7.11.x (untested)
7.10.x (untested)
7.9.x (untested)
7.8.x (untested)
7.7.x (untested)
7.6.x (untested)
7.5.x (untested)
7.4.x (untested)
7.3.x (untested)
7.2.x (untested)
7.1.x (untested)
7.0.x (untested)
6.1.x (untested)
6.0.x (untested)

You must login before you can report on package compatibility.

Package Information

  • Package owner: Dennis Öhman
  • Created: 10/11/2019
  • Current version 0.1
  • .net Version 4.7.2
  • License MIT
  • Downloads: 28