I've a custom content entity (created using Config pages module) which is used as a welcome screen / dashboard. Privileged super editors can edit those content entities, normal editors can only view it.
The config pages module itself does not provide routes to view modes (only to edit forms), so I used the core's generic _entity_view
to create routes for the normal editors myself:
This is my_module.routing.yml
my_module.view_config_pages:
path: '/admin/config_pages/{i_dont_want_no_parameter}'
defaults:
_entity_view: 'config_pages.full'
requirements:
_role: 'authenticated'
options:
_admin_route: true
parameters:
i_dont_want_no_parameter:
type: 'entity:config_pages'
This works with URLs like /admin/config_pages/1
, /admin/config_pages/2
etc... But I want to create nice, parameter-less, named routes to specific entity IDs. Something similar to my dummy-code below
my_module.view_welcome:
path: '/admin/welcome'
defaults:
_entity_view: 'config_pages.full'
requirements:
_role: 'authenticated'
options:
_admin_route: true
parameters:
yeah_no_parameter:
type: 'entity:config_pages'
id: 1
my_module.view_stats:
path: '/admin/stats'
defaults:
_entity_view: 'config_pages.full'
requirements:
_role: 'authenticated'
options:
_admin_route: true
parameters:
yeah_no_parameter:
type: 'entity:config_pages'
id: 2
Can this be done with _entity_view
in YAML files without coding a custom controller?