We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Problem

using count with content_custom

Hello Perch.

I'm using content_custom with a count variable to show a limited subset of some content. I'm also using a template with a repeater inside. I'm essentially trying to grab the first 8 items that have anything at all in this repeater. However the count, as expected I guess, seems to be including results that don't contain that criteria, so it only actually brings back one or two of the results I need.

<?php perch_content_custom('portfolio', array(
    'template' => 'award.html',
    'count' => 8,
)); ?>

Adding a filter to check that the item isn't empty simply returns nothing at all (I'm assuming because repeaters don't count as a single field to filter on, so nothing comes back as a match):

<?php perch_content_custom('portfolio', array(
    'template' => 'award.html',
    'count' => 8,
    'filter' => 'work_awards',
        'match' => 'neq',
    'value' => "",
)); ?>

Has anyone else ever tried doing something like this? How did you get around it?

Cheers for any pointers,

Liam

Liam Coates

Liam Coates 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can test for items in the repeater using repeaterID.fieldID.

Can I see the template?

Ah, no need!

Testing for the fieldID rather than the repeater itself was what fixed it. Once again I was indeed missing something blindingly obvious.

Thanks Drew!

Also Drew, I would mark your post as the solution, but it doesn't seem to give me the option - It's only allowing me to choose my own latest reply as a solution which, let's face it, isn't going to help anybody :) For anyone reading this, consider Drew's answer right on the money.