Simple Testimonials filter by custom attribute

Permalink
Anyone know how to filter the simple testimonials block by a custom attribute?
I want to show a different list of testimonials on different pages.

The testimonials have a unique reference/subject field (string) and in the block I would like to set that reference so only those testimonials are shown.

public function view()
    {
        $testimonialLimit = $this->limitQty;
        $testimonialPageLimit = $this->pageQty;
        $testimonialList = new TestimonialList();
        if ($testimonialPageLimit && !$testimonialLimit)
        {
            $testimonialList->setItemsPerPage($testimonialPageLimit);
            $factory = new PaginationFactory(\Request::getInstance());
            $paginator = $factory->createPaginationObject($testimonialList);
            $pagination = $paginator->renderDefaultView();
            $this->set('testimonialslist', $paginator->getCurrentPageResults());
            $this->set('pagination', $pagination);
            $this->set('paginator', $paginator);
        }else{

c5dragon
 
c5dragon replied on at Permalink Reply
c5dragon
Any insight on how to do this?
c5dragon replied on at Permalink Best Answer Reply
c5dragon
filter is available on all item lists in the core. It accepts 3 arguments column name, value and comparison (default is =)
$testimonialList->filter('field',$uniqueID);

$testimonialList->filter('e.Testimonial','012019');
$testimonialList = $testimonialList->getResults();

Thanks @deek87