listing_list_header_buttons
Allows adding and removing buttons from the listings list page. For example, where the submit new listing and layout switcher buttons appear.
You need to have a working knowledge of Hooks before you get started.
Parameters
| Name | Type | Description |
|---|---|---|
$buttons |
parameter |
|
$params |
parameter |
(array) associative array with contextual data |
Boilerplate Code
Use the boilerplate code to start using the filter, and add your own logic to modify the first argument and return it.
Clickfwd\Hook\Filter::add('listing_list_header_buttons', function($buttons, $params)
{
// Uncomment line below to view available data passed into hook
// fwd_dd($buttons, $params);
return $buttons;
});
Examples
Hide Submit Listing Button In Specific Categories
The submit listing button will show in all categories where the current user has permission to submit listings, but will be hidden in categories specified via the `$hideInCatIds` array. Hiding the button does not override the submit listing permission. To do that you should update the Access Settings directly in JReviews.
Clickfwd\Hook\Filter::add('listing_list_header_buttons', function($buttons, $params)
{
$hideInCatIds = [1, 2, 10, 20, 23];
if ($params['route'] !== 'categories.category') {
return $buttons;
}
if (in_array($params['params']['cat'], $hideInCatIds)) {
unset($buttons['submit-listing']);
}
return $buttons;
}, 10);
Source Files
/views/helpers/listing_helper.php