verbb / navigation

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

Building slugs that level in to account #355

Open 87Development opened 1 year ago

87Development commented 1 year ago

Question

It is possible to create slugs based on the hierachy? For example I have a hierachy that looks like this,

My current graphql preview implmentation just returns the url/uri/slug of the entry and not it's parent or hierachy?

query Components {
  navigationNodes(navHandle: "mainMenu") {
    title
    url
    element {
      slug
      title
      uri
    }
    children {
      title
      url
      element {
        title
        slug
        uri
      }
      children {
        title
        url
        element {
          title
          slug
          uri
        }
      }
    }
  }
}

Basically what I am wanting it a node to have a href of it's entries slug and it's parent's slug if it indeed has a parent. Is this possible?

Additional context

No response

engram-design commented 1 year ago

So long as I understand correctly, this isn't something that's possible or going to be incorporated. Navigation doesn't define the URL or slug of element nodes, that's defined by the element. This is so that your Navigation can define a structure that's independent of the elements you pick.

So you might have your entries in a structure with parent/child relationships (which affect the uri of the entries), but this is different to the structure in the navigation.

In your example, with jeans as the slug, if there's no parent entry relationship to our-clothes, then the uri of the entry won't reflect that, no matter how you set your hierarchy in Navigation. This is also because element nodes use the uri of the linked-to element, rather than the hierarchy. So you could need to have "Our Clothes" as a parent entry to "Jeans" to get the structure you are after.

Hope that makes sense?