Hi,
I used the "mymodule.links.task.yml" file to add a couple of tabs in the user profile tab and it works perfectly.
========================
lessons_tab:
route_name : lessons_tab
title: Lessons Manager
base_route: entity.user.canonical
weight: 10
lessons_add_tab:
route_name : lessons_add_tab
title: Add New Lesson
base_route: entity.user.canonical
weight: 10
========================
this is my mymodule.routing.yml file:
========================
lessons_tab:
path: '/lessons'
defaults:
_controller: '\Drupal\mymodule\Controller\LessonsController::content'
requirements:
_role: 'instructor + administrator'
lessons_add_tab:
path: '/lessons/add'
defaults:
_title: 'Add new lesson'
_form: '\Drupal\mymodule\Forms\LessonsAdd'
user: \d+
requirements:
_role: 'instructor + administrator'
========================
When I click on the new tabs my pages are shown correctly but the user profile tab disappear!
Anybody knows where is my mistake?
Maybe I have to invoke an api in my module to recreate the user profile tab?
Thanks && Marry Christmas Everybody!
Comments
I'm thinking that it's
I'm thinking that it's because /lessons isn't a sub-path of entity.user.canonical (/user). Try changing /lessons to /user/lessons and see if that helps.
this is the result!
Hi,
I did the following:
1) path: '/user/lezioni/add' and received the following error msg:
[20-Dec-2016 07:55:30 Europe/Rome] Uncaught PHP Exception RuntimeException: "Callable "Drupal\contact\Access\ContactPageAccess::access" requires a value for the "$user" argument." at /var/www/html/drupal8/core/lib/Drupal/Component/Utility/ArgumentsResolver.php line 142
2) path: '/user/{user}/lezioni/add' and received the following error msg:
page not found
I really don't know what to do!!!
Solved!
I studied a bit the core modules and solved the problem!
The routing.yml file must be like this:
lessons_add_tab:
path: '/user/{user}/lessons/add'
defaults:
_title: 'Add new lesson'
_form: '\Drupal\mymodule\Forms\LessonsAdd'
requirements:
_role: 'instructor + administrator'
options:
_admin_route: TRUE
user: \d+
the last three line are the solution.
Thanks bye