Jump to content
Ant

How to add favorite button to list page items using filters

Recommended Posts

Ant

Create templates/jreviews_overrides/filters/filter_functions.php

and in it put the following code
 

<?php
defined('MVC_FRAMEWORK') or die;

/* Add Favorite button to list page */
function add_favorite_button_list_page($buttons, $params)
{
   $listing = $params['listing'];

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

   ob_start();

   $listingHelper->favorite($listing);

   $favoriteButton = ob_get_clean();

   $buttons['favorite'] = $favoriteButton;

   return $buttons;
}

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

Hope someone finds this useful.

More filters can be found at https://docs.jreviews.com/?title=JReviews:Developers_Filters

Edited by Alejandro
Updated with simpler code

Share this post


Link to post
Alejandro

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Ant

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Ant

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Alejandro

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Ant

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Please refer to our Privacy Policy.