title: Drupal create custom block hook for rendering a dynamic menu
body: <p>How would one write a block hook that renders a custom menu depending on the current URL, with the active trail applied?  I cannot do it with a regular menus, since they are cached. With custom I mean different menu items for different users.</p>
  
  <p>An example menu could look like this when looking at Users X's profile</p>
  
  <pre><code>|-- User X's profile (active)
  |-- User X's groups
      |-- Group A
      |-- Group B
      |-- Group C
  </code></pre>
  
  <p>But if I browse to my own user profile, go to settings, the menu might look like this</p>
  
  <pre><code>|-- My profile
  |-- My settings
      |-- Profile settings (active)
      |-- Group settings
  |-- My groups
      |-- Group X
      |-- Group Y
      |-- Group Z
  </code></pre>
  
  <p>It would be very easy to just create a block that outputs this in plain HTML. But as said above, I need the active-trail applied on the links. And I also only want to edit the routes from the different menu hooks, not hard code or anything similar.</p>
  
  <p>Any suggestions?</p>