Skip to main content
added 51 characters in body
Source Link
MrUpsidown
  • 598
  • 1
  • 7
  • 23

I have created a module with its routing.yml file.

mymodule.dossier:
  path: '/dossiers/{node}/dossier'
  defaults:
    _entity_view: 'node.dossier_dossier'
  requirements:
    _permission: 'access content'

I have created a custom view mode (node.dossier_dossier) and the corresponding Twig template. If I go to dossiers/1/dossier, it works, and it displays the node with the dossier_dossier view mode and appropriate template.

node/1 has /dossiers/my-custom-path as its path alias, which is automatically set from the Pathauto module. If I try to access /dossiers/my-custom-path/dossier, it returns a Page not found error.

How can I make this route work for my nodes for both (default and path aliases) URLs?

Edit: I should maybe mention why I need that:

  • /dossiers/my-custom-path should display the node using the default view mode
  • /dossiers/my-custom-path/dossier should display the node using the dossier_dossier view mode
  • /dossiers/my-custom-path/abstract should display the node using yet another view mode (I'd create another route for that one presumably)

I have created a module with its routing.yml file.

mymodule.dossier:
  path: '/dossiers/{node}/dossier'
  defaults:
    _entity_view: 'node.dossier_dossier'
  requirements:
    _permission: 'access content'

I have created a custom view mode (node.dossier_dossier) and the corresponding Twig template. If I go to dossiers/1/dossier, it works, and it displays the node with the dossier_dossier view mode and appropriate template.

node/1 has /dossiers/my-custom-path as its path alias, which is automatically set from the Pathauto module. If I try to access /dossiers/my-custom-path/dossier, it returns a Page not found error.

How can I make this route work for my nodes for both (default and path aliases) URLs?

Edit: I should maybe mention why I need that:

  • /dossiers/my-custom-path should display the node using the default view mode
  • /dossiers/my-custom-path/dossier should display the node using the dossier_dossier view mode
  • /dossiers/my-custom-path/abstract should display the node using yet another view mode

I have created a module with its routing.yml file.

mymodule.dossier:
  path: '/dossiers/{node}/dossier'
  defaults:
    _entity_view: 'node.dossier_dossier'
  requirements:
    _permission: 'access content'

I have created a custom view mode (node.dossier_dossier) and the corresponding Twig template. If I go to dossiers/1/dossier, it works, and it displays the node with the dossier_dossier view mode and appropriate template.

node/1 has /dossiers/my-custom-path as its path alias, which is automatically set from the Pathauto module. If I try to access /dossiers/my-custom-path/dossier, it returns a Page not found error.

How can I make this route work for my nodes for both (default and path aliases) URLs?

Edit: I should maybe mention why I need that:

  • /dossiers/my-custom-path should display the node using the default view mode
  • /dossiers/my-custom-path/dossier should display the node using the dossier_dossier view mode
  • /dossiers/my-custom-path/abstract should display the node using yet another view mode (I'd create another route for that one presumably)
added 320 characters in body
Source Link
MrUpsidown
  • 598
  • 1
  • 7
  • 23

I have created a module with its routing.yml file.

mymodule.dossier:
  path: '/dossiers/{node}/dossier'
  defaults:
    _entity_view: 'node.dossier_dossier'
  requirements:
    _permission: 'access content'

I have created a custom view mode (node.dossier_dossier) and the corresponding Twig template. If I go to dossiers/1/dossier, it works, and it displays the node with the dossier_dossier view mode and appropriate template.

node/1 has /dossiers/my-custom-path as its path alias, which is automatically set from the Pathauto module. If I try to access /dossiers/my-custom-path/dossier, it returns a Page not found error.

How can I make this route work for my nodes for both (default and path aliases) URLs?

Edit: I should maybe mention why I need that:

  • /dossiers/my-custom-path should display the node using the default view mode
  • /dossiers/my-custom-path/dossier should display the node using the dossier_dossier view mode
  • /dossiers/my-custom-path/abstract should display the node using yet another view mode

I have created a module with its routing.yml file.

mymodule.dossier:
  path: '/dossiers/{node}/dossier'
  defaults:
    _entity_view: 'node.dossier_dossier'
  requirements:
    _permission: 'access content'

I have created a custom view mode (node.dossier_dossier) and the corresponding Twig template. If I go to dossiers/1/dossier, it works, and it displays the node with the dossier_dossier view mode and appropriate template.

node/1 has /dossiers/my-custom-path as its path alias, which is automatically set from the Pathauto module. If I try to access /dossiers/my-custom-path/dossier, it returns a Page not found error.

How can I make this route work for my nodes for both (default and path aliases) URLs?

I have created a module with its routing.yml file.

mymodule.dossier:
  path: '/dossiers/{node}/dossier'
  defaults:
    _entity_view: 'node.dossier_dossier'
  requirements:
    _permission: 'access content'

I have created a custom view mode (node.dossier_dossier) and the corresponding Twig template. If I go to dossiers/1/dossier, it works, and it displays the node with the dossier_dossier view mode and appropriate template.

node/1 has /dossiers/my-custom-path as its path alias, which is automatically set from the Pathauto module. If I try to access /dossiers/my-custom-path/dossier, it returns a Page not found error.

How can I make this route work for my nodes for both (default and path aliases) URLs?

Edit: I should maybe mention why I need that:

  • /dossiers/my-custom-path should display the node using the default view mode
  • /dossiers/my-custom-path/dossier should display the node using the dossier_dossier view mode
  • /dossiers/my-custom-path/abstract should display the node using yet another view mode
improved grammar and formatting
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

I have created a module and awith its routing yaml.yml file:.

mymodule.dossier:
  path: '/dossiers/{node}/dossier'
  defaults:
    _entity_view: 'node.dossier_dossier'
  requirements:
    _permission: 'access content'

I have created a custom view mode node.dossier_dossier(node.dossier_dossier) and the corresponding twigTwig template.

Now if If I go to dossiers/1/dossierdossiers/1/dossier, it works, and it displays the node with the dossier_dossierdossier_dossier view mode and appropriate template.

This node/1node/1 has an automatic URL alias of /dossiers/my-custom-path (Pathauto)/dossiers/my-custom-path as its path alias, which is automatically set from the Pathauto module.

  If I try to access /dossiers/my-custom-path/dossier/dossiers/my-custom-path/dossier, it returns a pagePage not found error.

How can I make this route work for my nodes for both How can I make this route work for my nodes for both (default and path aliases) URLs?URLs?

I have created a module and a routing yaml file:

mymodule.dossier:
  path: '/dossiers/{node}/dossier'
  defaults:
    _entity_view: 'node.dossier_dossier'
  requirements:
    _permission: 'access content'

I have created a custom view mode node.dossier_dossier and the corresponding twig template.

Now if I go to dossiers/1/dossier it works and it displays the node with the dossier_dossier view mode and appropriate template.

This node/1 has an automatic URL alias of /dossiers/my-custom-path (Pathauto).

  If I try to access /dossiers/my-custom-path/dossier, it returns a page not found.

How can I make this route work for my nodes for both (default and path aliases) URLs?

I have created a module with its routing.yml file.

mymodule.dossier:
  path: '/dossiers/{node}/dossier'
  defaults:
    _entity_view: 'node.dossier_dossier'
  requirements:
    _permission: 'access content'

I have created a custom view mode (node.dossier_dossier) and the corresponding Twig template. If I go to dossiers/1/dossier, it works, and it displays the node with the dossier_dossier view mode and appropriate template.

node/1 has /dossiers/my-custom-path as its path alias, which is automatically set from the Pathauto module. If I try to access /dossiers/my-custom-path/dossier, it returns a Page not found error.

How can I make this route work for my nodes for both (default and path aliases) URLs?

Source Link
MrUpsidown
  • 598
  • 1
  • 7
  • 23
Loading