verbb / navigation

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

New Navigation Node Type for Section Handles #350

Closed sarahschuetz closed 1 year ago

sarahschuetz commented 1 year ago

What are you trying to do?

We would like to build a navigation which is built using a combination of the navigation plugin and entry structures. The goal is to primarily use the navigation plugin for the basic structure of the navigation, as well as parts of the linked sites. Additionally, we would like to be able to place new navigation node types, where a section handle can be selected and all entries of the selected section are shown at this point in the navigation.

NavigationPluginFR

What's your proposed solution?

We would like a new type of navigation node, where a section (or maybe only structures 🤔) can be selected. The data returned for this node could either be all section entries directly, the section handle, or the corresponding entry query (probably better than the entries directly, so the user has control over eager loading).

NavigationPluginFR2

Additional context

Why we want to do this:

engram-design commented 1 year ago

I think in practice that might be awkward to actually use, as the section node you pick is technically a collection of entries - not even Navigation nodes. As such, this really breaks the Navigation API where only Navigation Nodes exist in a navigation (yes, nodes can link to other elements). I see your suggestion of either returning an entries element query or just the section handle - either would be okay.

You can certainly achieve this with a custom node type, or even using the Passive node type to denote what node you want to represent the section you want to fetch entries from. I'm probably going to say that it's not probably going to make it as a core node type within Navigation, but it's absolutely possible to create this yourself.

I see your use case though, where you're just going to be double-handling things by keeping the section and navigation "in sync" with changes, which would be a little bit of a nightmare (Navigation will update titles when they're changed).

sarahschuetz commented 1 year ago

I guess using the Passive node type would work. However, we will need the passive node type as well, so we will need a possibility to distinguish between the two. I guess a quick and still clean way would be to use a custom module to extend the navigation plugin and then copy (or might even extend) the Passive node type and just change the name.

engram-design commented 1 year ago

Yep, a new custom node type would be my recommended approach. Either extending the Passive node type, or take inspiration from that should get you off to a great start.