I've a very simple task to do in Drupal 8, but I've hard time to find the proper way to do that.

I have a simple menu like this (all basic pages).

  • Company
    • Organization
    • Values
    • Terms
  • Services
  • Team

And when we go to Company page, I want to display all three sub-pages content in there.

How do I get the sub page node ID from the current menu? In Drupal 7, I'd go with something like menu tree data, and parse the URL to get the node ID; I'm sure we can do something similar with Drupal 8, but I can't find a way.

  • Company page, I want to display all three sub-pages content in there is there a reason why you need to also have them in separate pages? Seems kinda pointless to click on organization and see the same thing you saw in company. – No Sssweat May 7 '16 at 9:03

I think you're approach is just from the wrong end, the menu is just a list of links and not meant to control content.
What you want to do is:

  • Make "Company" as a views > page or a views blocks within etc.
  • Make a taxonomy reference for the sub pages or make them separate entity or content type, in order to specify your sub pages in views.
  • Create view_mode like teaser to format their subpage display.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.