Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building slugs that level in to account #355

Open
87Development opened this issue May 31, 2023 · 1 comment
Open

Building slugs that level in to account #355

87Development opened this issue May 31, 2023 · 1 comment
Labels

Comments

@87Development
Copy link

Question

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

  • Clothing (entry with slug of our-clothes)
    1. Clothing Styles (passive no slug)
      a. Jeans (entry child of "Clothing" with slug of jeans, so would expect nav menu href to be "our-clothing/jeans")
      b. Jumpers ("our-clothing/jumpers")
      c. Hoodies ("our-clothing/hoodies")
      d. T-shirts ("our-clothing/t-shirts")

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
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants