JReviews logo
Guides My site
← All guides Community guide

Add an inquiry button to listing list pages

B Alejandro
Thread started by Brill. Contributors Alejandro.
Thread started
Last updated

What you’ll achieve

Let eligible visitors open a listing inquiry directly from a list page.

My site

Platform
JReviews version

Show an Inquiry button on list pages so visitors can contact a listing's configured recipients.

Enable inquiries and choose recipients

Enable inquiries for the relevant listings, configure the recipients, and grant the intended groups inquiry access. The button cannot supply missing recipients or grant inquiry permission.

Keep the customization in your JReviews overrides. Start a new PHP file with <?php followed by defined('MVC_FRAMEWORK') or die;. In an existing file, add the callback without repeating the opening tag or guard. If a snippet includes those lines, keep each only once.

JReviews 6 Early Access

Enable Listing List Pages in Early Access.

Show the Inquiry action

Joomla. Use templates/jreviews_overrides/hooks.php.

WordPress. Use jreviews_overrides/hooks.php.

Add the callback marked with +. The standard card and table layouts hide the built-in Inquiry button. The callback shows it on list pages; its name in the code is inquire.

  • If hooks.php already exists, add the marked lines at the end of the file. The copy button copies only those lines.
  • If you are creating hooks.php, type the two dimmed lines first, then add the marked lines below them.
<?php
defined('MVC_FRAMEWORK') or die;

fwd_add_filter('jreviews:listing:actions.listings_list', function (array $result, $listing): array {
    $result['exclude'] = array_values(array_diff($result['exclude'] ?? [], ['inquire']));

    if (($result['include'] ?? null) !== null) {
        $result['include'] = array_values(array_unique([...$result['include'], 'inquire']));
    }

    return $result;
}, 20, 2);

The code adds Inquiry to any list of allowed buttons and removes it from the list of hidden buttons. Inquiry permissions still decide who can use it.

If you use a custom card, keep the supplied footer section that displays its buttons. In list and table overrides, keep the actions component and its listings_list setting. The code cannot show Inquiry if your template omits the button section or another customization removes it.

See Listing actions for custom button conditions.

JReviews 5 and v6 Legacy

Add the Inquiry button

Joomla. Use templates/jreviews_overrides/filters/filter_functions.php.

WordPress. Use jreviews_overrides/filters/filter_functions.php.

Add the code below to place the existing Inquiry button beside each eligible listing.

function add_inquiry_button_list_page($buttons, $params)
{
   $listing = $params['listing'];

   $listingHelper = ClassRegistry::getClass('ListingHelperHelper');

   ob_start();

   $listingHelper->inquiry($listing);

   $inquiryButton = ob_get_clean();

   $buttons['inquiry'] = $inquiryButton;

   return $buttons;
}

Clickfwd\Hook\Filter::add('listing_list_action_buttons', 'add_inquiry_button_list_page', 10);

Check the button and visitor permissions

Open card and table layouts as a permitted member and as a guest. Open the inquiry and confirm it targets the intended listing. Guests may receive an account prompt. Check a listing with inquiries disabled and confirm it does not offer an unauthorized inquiry.

Learn more