verbb / navigation

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

Passive node type for structural distinction #183

Closed Mosnar closed 4 years ago

Mosnar commented 4 years ago

What are you trying to do? We often design our footers such that it's multiple columns of links with the top one being bold to designate a group. Sometimes, there's extra space, so we have a second group in the same column. We can make this work by using top level nodes as column designators, 2nd level nodes as groups, and 3rd level nodes as items in those groups. Right now, we have to use a "Custom" link type with a blank URL. Ideally, there would be a "Passive" node without any link options, purely for designating things like columns.

I tweaked the Verbb footer nav as an example - notice the additional group in the last column: image

engram-design commented 4 years ago

I'm a tiny bit hesitant to add this as a default node type, for a few reasons. Firstly - to not overwhelm users with options for node types, and secondly because "Passive" node doesn't quite work for me in terms of it's descriptiveness. But then I also don't have any better alternative - terms like "Divider" are too specific, and don't really apply in your case. As a user (client) adding a "blank" node seems not that useful, but I can see from your example, it's a valid use-case.

You could certainly register your own "Passive" node type if you find you're using this a lot. See docs.

I'll give it some further thought.

maxstrebel commented 4 years ago

Honestly I'd also dig a passive node type. It's a recurring wish from users. Especially for Headings and Dividers.

engram-design commented 4 years ago

@maxstrebel You can create your own custom node type for any of these things. I'm just concerned about having a stack of different things - "Passive", "Heading", "Divider" - all of which essentially do the same thing (you can choose how you want to handle these in your templates).

Again, I'm hesitant to add too many of these new node types to stock installations, if they can be achieved with reasonable ease for your specific projects. But, if enough people kick up a fuss, then happy to.

maxstrebel commented 4 years ago

Hey @engram-design, I completely understand your stance. And I agree that complexity should be kept to a minimum.

But I think that @Mosnar did the right thing by calling it a passive Node. This implies an abstract implementation of headings, dividers, etc. by simply having one alternative – a passive node type without URL/Relation.

As you can extend the Node Fields, the combination of a "passive" node and fields would theoretically enable you to do all sorts of things the Craft way. I hope you consider it.

That said, thanks for all the great work Verbb does for the community.

engram-design commented 4 years ago

I'm very open to adding this, as its a pretty common thing. I'm just not sure on the terminology of "Passive", particularly for clients, but I like the abstraction for reasons you've mentioned.

maxstrebel commented 4 years ago

That's great! Maybe "decorator" or "UI Element" (to reference Craft's 3.5 UI Elements)?

engram-design commented 4 years ago

Settled on "Passive" in the end. See 1.4.0

proimage commented 3 years ago

As a follow-up to this, what's the conditional for detecting passive nodes in the template? node.type seems to be the attribute, but it equates to an unwieldy verbb\navigation\nodetypes\PassiveType string. And even so, when I do a {% switch node.type %}, I can't seem to get a {% case %} to match the passive type.

engram-design commented 3 years ago

That's indeed the way to check, but not ideal I suppose. You could also use node.nodeTypeLabel == 'passive'.

Added node.isPassive() in 1.4.9