Just a quick Kentico menu solution

Thought I'd post this solution to what I would have thought was a fairly common problem with this product.

I'm using an ASP.Net CMS called Kentico CMS.  It is quite good - much more friendly than some others I've used recently.  I've been trying to get the CSS Menu control set up so that it will always show root pages, and also the pages beneath the current page.  It wasn't as easy as I thought.

For example:

Home
About
 - Our Products
 - Our Services
    - Programming
    - Design
Links
 - Friends
Contact

In the example above, no matter where I was on the site, I wanted to see Home, About, Links, and Contact on the menu.  If I was on the About page, then the Our Products and Our Services links should be shown as well.  So I'm looking for the root pages and the children of the current page.  I thought this was pretty standard menu behaviour, but it took me a couple of hours to figure out.

Here's the solution:

In the design view, edit the properties of the menu by clicking on its gears icon, go to the Content Filter section and put the following query in the WHERE condition field:

NodeAliasPath LIKE '{&/{0}/%&}' OR NOT NodeAliasPath LIKE '/%/%'
This gets all items under the current one {0}, or anything that's not a root element.  You'll have to make sure the Maximum nesting level is set appropriately, but that's it.

Hopefully someone else with the same problem will stumble across this and save themselves an hour or two.

Damian Brady

I'm an Australian developer, speaker, and author specialising in DevOps, MLOps, developer process, and software architecture. I love Azure DevOps, GitHub Actions, and reducing process waste.

--