Step 1 - Creating a My dashboard tab¶
My dashboard is the front page that you visit after logging in to the Back Office. You can also get to it from any other page by selecting the site logo in the top left corner. By default, the My dashboard page contains following blocks: "My content" and "Common content", which list Content items and Media.
In this step you will add a new tab to the "Common content" block in the dashboard.
This tab, called "Articles", will list ten most recently modified Content items of the Content Type article
.
Tip
To be able to view the results of this step, create a few Content items of the type "Article".
Register a service¶
First, add the following block to config/services.yaml
. Place the block indented, under the services
key:
1 2 3 4 5 6 |
|
The tags indicate that this is a tab on the My dashboard page that will be placed in the "Common content" block.
This configuration points to the EveryoneArticleTab.php
file, which you now need to create.
Create a tab¶
Create an EveryoneArticleTab.php
file in src/Tab/Dashboard/Everyone
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
Tip
The tab extends AbstractTab
.
There are also other tab types that you can extend.
The tab also implements OrderedTabInterface
(see line 17), which enables you to define the order in which the tab is displayed on the My dashboard page.
This is done using the getOrder
method (see line 47).
The rendering is done using the built-in all_content.html.twig
template,
which ensures the tab looks the same as the existing tabs.
Check results¶
Tip
If you cannot see the results or encounter an error, clear the cache and reload the application.
At this point you can go to the My dashboard page in the Back Office: select the site logo in the top left corner. In the "Common content" block you can see the new "Articles" tab with the first ten articles in the Repository.