listing_list_header_buttons

Filter Hook Listings List Since 3.6.0

Allows adding and removing buttons from the listings list page. For example, where the submit new listing and layout switcher buttons appear.

Parameters

$buttons

$params

(array) associative array with contextual data

You need to have a working knowledge of Hooks before you get started.

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
  // For JReviews 3.x and earlier use dd instead of fwd_dd
  // fwd_dd($buttons, $params);
  
  return $buttons;
});
Development & Support
Customizations are not included with support. We provide this information to make it easier for developers to extend the functionality. From time to time we may have some availability for custom work. Get in touch to see if there's an opportunity to work together.

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

  • /views/helpers/listing_helper.php