Get a count from a perch_content_custom

  • Is it possible to get the a count of the number of items returned from perch_content_custom?

    The use case is as follows:

    Our client is adding special offers to their website. The offers are categorised 'beds' or 'flooring'. I want to be able to get a count for either so I can show a conditional menu.

    I've tried:

    1. //PHP
    2. $floorCount = perch_content_custom('Clearance Offers', array(
    3. 'template' => 'offers/floor_count.html',
    4. ), true);
    5. //Floor count html template:
    6. <perch:if id="type" value="flooring" match="eq">
    7.     <perch:content id="perch_item_count"/>
    8. </perch:if>

    However that returns the total count of all offers not just flooring.

    Is this possible?

  • Just dawned on me to filter it on the php call:

    1. $floorCount = perch_content_custom('Clearance Offers', array(
    2. 'template' => 'offers/floor_count.html',
    3. 'filter' => 'type',
    4. 'match' => 'eq',
    5. 'value' => 'flooring',
    6. ), true);

    Then include the html template in a perch:after tag to get the very last result

    1. <perch:after><perch:content id="perch_item_count"/></perch:after>