Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Latest commit

 

History

History
52 lines (38 loc) · 2.27 KB

integration-guide.md

File metadata and controls

52 lines (38 loc) · 2.27 KB

Integration guide

Meganav was designed to be as clean and easy for developers as it is for editors to use.

Strongly typed models

Out of the box Meganav can return strongly typed models for a given navigation.

The following properties are available in the MeganavItem class:

Property Type Description
Id Int The node ID of the selected content item. For external linking nav items this will be "0"
Udi GuidUdi The node UDI of the selected content item. For external linking nav items this will be null
Title String The link title, often the node name
Target String The link target
Url String The link url
QueryString String The link querystring / anchor
Level Int The level in the overall navigation that the current item sits at
Content IPublishedContent The IPublishedContent for the selected content item. For external linking nav items this will be null
Children List The picked child / sub items for the current item
Culture String The link culture

Implementing Razor

MeganavV8 was designed to closely follow the "Umbraco way" of doing things so we don't impose our own styles or markup on you.

It's easy to implement in your own Razor:

<ul>
    @foreach (var item in Model.Value<IEnumerable<MeganavV8Item>>("megaNavV8"))
    {
        <li>
            ...
        </li>
    }
</ul>

Note: For large navigations with multiple levels it is highly recommended that you cache your navigation for optimal performance.

Complex navigation

MeganavV8 can build any size of navigation, from a small single level list to a large multi-level menu.

Based on the flexible implementation described above it would be possible to create a complex navigation varying on a number of factors, such as:

  • The level of an item (available via x.Level)
  • The doctype alias of an item (available via x.Content.DocumentTypeAlias)
  • Any custom property (available via x.Content.Value("..."))
  • Countless more...!