verbb / navigation

A Craft CMS plugin to create navigation menus for your site.
Other
90 stars 22 forks source link

Add a condition rule for hierarchy levels #396

Closed MoritzLost closed 1 month ago

MoritzLost commented 2 months ago

What are you trying to do?

I have some fields that I only want to display for root nodes (hierarchy level 1). In this case, the first level nodes are passives that each contain a mega menu structure. The mega menu includes some additional content (e.g. a headline, an image) that should be editable for the root nodes. However, all other hierarchy level should not show these fields, because they don't use them.

Nodes already support element condition rules, but there is no condition rule for the level property:

All available options for element condition rules for nodes

What's your proposed solution?

Add a condition rule for the level where the field can be limited to only be visible for nodes at one or more specific levels. This would also address other use-cases. For example, in some situations it would be useful to only show a field for the second hierarchy level, or every level but the first one, etc.

Additional context

Quick mockup (wording could be better):

Screenshot 2024-07-02 at 16 49 09

Screenshot 2024-07-02 at 16 49 26

engram-design commented 2 months ago

What version of Navigation are you on? The level attribute is certainly available for me

image
MoritzLost commented 2 months ago

@engram-design Very curious 🤔 We're on the latest release 3.0.1, and Craft 5.2.1.

I've checked the source code, I can see the NodeCondition class that's registering LevelConditionRule and TypeConditionRule, but neither of those are showing up in the interface. Any ideas?

engram-design commented 2 months ago

Ah, I see there's an issue with it for Craft 5. Fixed for the next release. To get this early, run composer require verbb/navigation:"dev-craft-5 as 3.0.1".

MoritzLost commented 2 months ago

@engram-design Works perfectly, thanks!

engram-design commented 1 month ago

Fixed in 3.0.2