jreviews-cp:sidebar_navigation
Filter the entire JReviews administration sidebar navigation. Use to insert or modify entries in any existing section (browse, setup, configuration, layout-customizer, addons, maintenance, support) by matching on the section's `name` key.
You need to have a working knowledge of Hooks before you get started.
Fires after the core sections and the Addons section have been combined into a single collection, before empty sections are stripped.
Parameters
| Name | Type | Description |
|---|---|---|
$navigationLinks |
\FWD\Illuminate\Support\Collection |
Collection of section arrays. Each section has `heading`, `name`, and `links` keys; `links` is an array of entries with `type`, `label`, and `do` keys. |
Boilerplate Code
Use the boilerplate code to start using the filter, and add your own logic to modify the first argument and return it.
fwd_add_filter('jreviews-cp:sidebar_navigation', function($navigationLinks)
{
// Your code here
return $navigationLinks;
});
The , 20, N after your callback are the hook priority and the number of arguments your callback accepts. By default, a hook passes your callback only its first argument; for a filter, that is the value being filtered, so a simple function($value) { ... } needs nothing extra. If your callback declares more parameters, such as function($value, $listing) { ... }, you must add N (the parameter count, 2 here). Because N is the fourth argument to fwd_add_filter() or fwd_add_action(), you must also pass the priority (20 is the default). Leaving these off when your callback expects extra parameters causes a Too few arguments to function ... fatal error.
Examples
Append entries to an existing section
Add admin pages to the existing Browse section, mirroring how the PaidListings add-on registers Orders and Transactions browse pages.
\FWDHook::addFilter('jreviews-cp:sidebar_navigation', function ($links) {
return $links->map(function ($section) {
if (! isset($section['name'])) {
return $section;
}
if ($section['name'] === 'browse') {
$section['links'][] = ['type' => 'route', 'label' => 'Orders', 'do' => 'paidlistings-cp::pages.browse-orders'];
$section['links'][] = ['type' => 'route', 'label' => 'Transactions', 'do' => 'paidlistings-cp::pages.browse-transactions'];
}
return $section;
});
});
Source Files
app/Http/CP/Yoyo/PrimarySidebar.php