You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/development/modules.md
+39-11Lines changed: 39 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -112,8 +112,9 @@ This would add a breadcrumb that would look like `Add-Ons -> [Add-On Name] -> Se
112
112
### Sidebar
113
113
If your add-on has multiple Control Panel pages, a sidebar can be incredibly helpful for your users to easily navigate between pages. Sidebars can either be generated automatically or manually.
114
114
115
-
#### Automatically Generate Your Sidebar
116
-
We can use the `make:sidebar` CLI command to generate a sidebar file for us.
115
+
Both of these options start with generating your sidebar class using the CLI.
116
+
117
+
We use the `make:sidebar` CLI command to generate a sidebar file for us.
117
118
118
119
```
119
120
$ php system/ee/eecli.php make:sidebar
@@ -156,7 +157,8 @@ class Sidebar extends AbstractSidebar
156
157
}
157
158
```
158
159
159
-
That's it! Our `Sidebar` class will scan our `Mcp` folder for all available Control Panel routes and automatically create respective entries in our sidebar. There's no need to add the sidebar to your Control Panel page as it will automatically be added when the page is rendered.
160
+
#### Automatically Generate Your Sidebar
161
+
If you'd like to have your sidebar automatically generated then that's it! The `Sidebar` class will scan our `Mcp` folder for all available Control Panel routes and automatically create respective entries in our sidebar. There's no need to add the sidebar to your Control Panel page as it will automatically be added when the page is rendered.
160
162
161
163
Example:
162
164
@@ -178,14 +180,40 @@ Would produce a sidebar in the Control Panel like this:
You can take this a step further by adjusting the following properties in your `Mcp` files to adjust how sidebar items are displayed:
182
-
-**`protected $sidebar_title (string)`** - By default the sidebar link text is based on your route's name. This property will overwrite the text displayed for this route.
183
-
-**`protected $sidebar_icon (string)`** - The Font Awesome icon you wish to display next to the sidebar link for this route.
184
-
-**`protected $sidebar_is_folder (bool)`** -
185
-
-**`protected $sidebar_is_list (bool)`** -
186
-
-**`protected $exclude_from_sidebar (bool)`** - Exclude this route from the sidebar.
187
-
-**`protected $sidebar_divider_before (bool)`** - Inserts a divider in the sidebar before
188
-
-**`protected $sidebar_divider_after (bool)`** -
183
+
You can take this a step further by adjusting the following properties in your Control Panel routes (`Mcp/[route_name].php`) to adjust how sidebar items are displayed:
184
+
##### `protected $sidebar_title (string)`
185
+
By default the sidebar link text is based on your route's name. This property will overwrite the text displayed for this route.
186
+
187
+
##### `protected $sidebar_icon (string)`
188
+
The Font Awesome icon you wish to display next to the sidebar link for this route.
189
+
190
+
##### `protected $sidebar_priority (int)`
191
+
Give this route a higher priority in the sidebar. Higher priority items will appear first in the sidebar.
192
+
193
+
##### `protected $exclude_from_sidebar (bool)`
194
+
Exclude this route from the sidebar.
195
+
196
+
##### `protected $sidebar_divider_before (bool)`
197
+
Inserts a divider in the sidebar before the link to this route.
198
+
199
+
##### `protected $sidebar_divider_after (bool)`
200
+
Inserts a divider in the sidebar after the link to this route.
201
+
202
+
203
+
You can even modify the generated sidebar in the `process()` method of your `Mcp/Sidebar.php` file by utilizing the [`CP/Sidebar Service`](development/services/sidebar.md).
204
+
205
+
#### Manually Generate Your Sidebar
206
+
207
+
We will set the `$automatic` property in our `Mcp/Sidebar.php` file to `false`.
208
+
209
+
```
210
+
public $automatic = false;
211
+
```
212
+
213
+
This tells our Sidebar class not to automatically create any sidebars.
214
+
215
+
From here you can utilize utilize the [`CP/Sidebar Service`](development/services/sidebar.md) in the `process()` method of our Sidebar class to manually create your sidebar and all related items.
Copy file name to clipboardExpand all lines: docs/development/services/sidebar.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,12 @@ lang: php
15
15
16
16
[TOC]
17
17
18
+
## Automatically Created Sidebars
19
+
If you are automatically generating a sidebar in your add-on you can use either of these methods to customize the sidebar further:
20
+
- Modify the sidebar on every page load in the in the `process()` method of your `Mcp/Sidebar.php` file. The sidebar object is available using `$this->getSidebar()` You can also loop through each sidebar item with $this->getItems()`
21
+
- Modify the sidebar only when a specific route is loaded by accessing the sidebar instance in the `process()` function of the route file (`Mcp/[route_name].php`).You can modify the sidebar item connected to the current route by using `$this->getCurrentSidebarItem()` with the [BasicItem Methods](#basicitem-methods) listed below. You can also use `$this->getSidebar()` to get the entire sidebar instance.
0 commit comments