using content_custom to pull data from a repeater field

  • Hi Guys,

    I'm a little stumped on this.

    I have a region on my contact page 'Contact Details':

    1. <perch:repeater id="contactDetailRows" label="Contact Detail Items">
    2. <tr>
    3. <td><perch:content id="contactDetailTitle" label="Title" type="text"></td>
    4. <td><perch:content id="contactDetailItem" label="Contact Information" type="text"></td>
    5. </tr>
    6. </perch:repeater>

    I want to pull out the phone number from an item in this repeater. perch has given the field I want to grab the data from an id of 'perch_80_contactDetailRows_1_contactDetailItem'

    PHP: Here is my content_custom
    1. <?php
    2. perch_content_custom('Contact Details', [
    3. 'page'=>'/contact-us.php',
    4. 'template'=>'_footer_phonefax.html',
    5. 'filter'=>'contactDetailRows.perch_80_contactDetailRows_1_contactDetailItem',
    6. 'sort-order'=>'DESC',
    7. ]);
    8. ?>

    Am i calling the correct field in my content template?

    Code: my _footer_phonefax.html content file
    1. P: <perch:content id="perch_80_contactDetailRows_1_contactDetailItem" type="text">

    Where I want this to show is showing the 'P:' so the template is working, it's just not pulling the field data in.

  • Hi,

    You cannot filter repeater items. You can remove the filter:

    1. perch_content_custom('Contact Details', [
    2. 'page'=>'/contact-us.php',
    3. 'template'=>'_footer_phonefax.html',
    4. ]);

    And update your template to only output what you need. Assuming phone number is always the first item:

    1. <perch:repeater id="contactDetailRows">
    2. <perch:if exists="perch_item_first">
    3. <!--* output the first item of the repeater *-->
    4. P: <perch:content id="contactDetailItem" type="text">
    5. </perch:if>
    6. </perch:repeater>
  • Yes, you can:

    1. <perch:repeater id="contactDetailRows">
    2. <perch:if id="perch_item_index" value="2">
    3. P: <perch:content id="contactDetailItem" type="text">
    4. </perch:if>
    5. </perch:repeater>

    Or you can check against the value of contactDetailTitle if you know what it is:

    1. <perch:repeater id="contactDetailRows">
    2. <perch:if id="contactDetailTitle" value="Phone">
    3. P: <perch:content id="contactDetailItem" type="text">
    4. </perch:if>
    5. </perch:repeater>