1
  • I created custom node type, let's say "My Node".
  • I created custom node display type (at /admin/structure/display-modes/view), let's say "Specialized Display".
  • Configured the "Specialized Display" for "My Node" - configured some fields, their order, etc.
  • How can I create a page on path "node/*/specialized-display" for "My Node" nodes using "Specialized Display"? (I.e. reject "node/123/specialized-display" if "node/123" is not "My Node", but e.g. "story".)
  • How can I make a tab appear in node context menu (the one which contains "View", "Edit", "Delete" tabs)?
  • Bonus question: how can I make URL automatic alias(es) "[alias of node/%]/specialized-display"?

What I tried

Created view page, path "node/%/specialized-display", use contextual filter (to reject different node types, use argument for node selection and to alter page title).

Problems:

  • Couldn't find out how to add it to the node context menu.
  • It creates redundant node title on the page (one for whole page and one for item in view). Couldn't find out how to remove it, but it's not that big problem, I'll remove is using CSS (although accessibility is going to be damaged).

My system: Drupal version: 8.8.3

0

First question: First you are going to want to set your views path to: node/%node/specialized-display. Then, in the contextual filter, under "WHEN THE FILTER VALUE IS AVAILABLE OR A DEFAULT IS PROVIDED" check off: Specify validation criteria. Finally, select "Content" from the dropdown and select your node type.

Second Question: This guide explains how to add contextual links, all you are going to need a basic custom module with a routing.yml file. You can set the route to the view. Hint, Drupal console's drupal debug:router is a great way to find the route to your view. https://www.drupal.org/docs/8/api/menu-api/providing-module-defined-contextual-links#s-rendering-contextual-links

Third question: I've had my best luck with the sub-pathauto module to make the aliased routes. https://www.drupal.org/project/subpathauto

Thoughts... I am using this setup on two sites so far and this works pretty well. Sub-Pathauto seems to behave fairly well. I do have one tip though, when initially building my views, I disable it, so that I can ensure everything works before I add the extra layer.

Other thoughts... This could be done through traditional custom views processing. If you have a big site, it may be the way to go. I haven't tested Sub-Pathauto at large scale, this is currently something I am experimenting with.

| improve this answer | |
  • 1
    I'll check this later - I can work on this project mostly only during weekends. But at first look, it looks great. (Point is: I'm not ignoring this answer.) – Tom Mar 18 at 8:09
  • I missed your last bullet, just saw it on this pass. You must be rendering your page title in the blocks and on the node. You can choose to render different view modes. Personally I use display suite, select "reset", go to full content and remove the title. WHat I'm saying is this comes down to how your site is setup somewhat. Maybe ask a new question with those extra details added once you have this working. Glad your not ignoring my answer! Good luck! – Ryan Hartman Mar 18 at 14:23

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.