Jump to content

How to add favorite button to list page items using filters


Ant

Recommended Posts

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
Link to comment
  • 3 weeks later...
  • 8 months later...
  • 1 month later...
×
×
  • Create New...