Forum

Thread tagged as: Question

Content custom on repeaters

Hi All,

Am i right in thinking i cant run content custom on an id that resides within a repeater?

Steve Forbes

Steve Forbes 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You might need to more closely define 'run'. Most things within a repeater can be accessed via repeater_id.field_id but I'd need to know exactly what you're trying to do.

So i have a reviews.php page with a content region of

<?php perch_content('Reviews'); ?>

And i wish to RAND call 3 from the field_id of datePublished to the index.php

<?php perch_content_custom('Reviews', array(
        'page'=>'/reviews.php',
        'template'=>'reviews-featured.html',
        'sort'=>'review.datePublished',
        'sort-order'=>'RAND',
        'count'=>3
    )); 
?> 

my repeater id is

<perch:repeater id="review" label="Review">
Drew McLellan

Drew McLellan 2638 points
Perch Support

What result are you getting?

no output

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you turn on debug for the page, what output do you get?

Ok let me amend, the output is in fact fine but not restricted to a count of 3. Debug below. cheers for the help.

<div class="debug" style="clear:both;">
DIAGNOSTICS:<br />
<span style="color: purple; margin: 0.5em 0; padding-left: 0.5em; border-left: 2px solid silver; display: block;">SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Reviews' AND (regionPage='/reviews.php' OR regionPage='*')<br />
</span><span style="color: purple; margin: 0.5em 0; padding-left: 0.5em; border-left: 2px solid silver; display: block;">SELECT * FROM ( SELECT  idx.itemID, c.regionID, idx.pageID, c.itemJSON,  idx2.indexValue as sortval  FROM perch2_content_index idx <br />
                            JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID<br />
                            JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev   AND idx2.indexKey='review.datePublished'  WHERE ((idx.regionID='3' AND idx.itemRev='37')) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev<br />
                    ) as tbl GROUP BY itemID  ORDER BY RAND() LIMIT 0, 3<br />
</span><span style="color: black; margin: 0.5em 0; padding-left: 0.5em; border-left: 2px solid silver; display: block;">Using template: /templates/content/reviews-featured.html<br />
</span><span style="color: purple; margin: 0.5em 0; padding-left: 0.5em; border-left: 2px solid silver; display: block;">SELECT * <br />
                    FROM perch2_blog_sections<br />
                    WHERE sectionSlug='Listings'<br />
                    LIMIT 1<br />
</span><span style="color: purple; margin: 0.5em 0; padding-left: 0.5em; border-left: 2px solid silver; display: block;">SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0<br />
</span><span style="color: purple; margin: 0.5em 0; padding-left: 0.5em; border-left: 2px solid silver; display: block;">SELECT SQL_CALC_FOUND_ROWS DISTINCT p.* FROM perch2_blog_posts p  WHERE  postStatus='Published' AND postDateTime<='2014-07-18 08:18:00'  AND  sectionID='2' ORDER BY postDateTime DESC LIMIT 0, 4<br />
</span><span style="color: purple; margin: 0.5em 0; padding-left: 0.5em; border-left: 2px solid silver; display: block;">SELECT FOUND_ROWS() AS `count` <br />
</span><span style="color: black; margin: 0.5em 0; padding-left: 0.5em; border-left: 2px solid silver; display: block;">Using template: /templates/blog//post_in_list_all.html<br />
</span><span style="color: purple; margin: 0.5em 0; padding-left: 0.5em; border-left: 2px solid silver; display: block;">SELECT c.*<br />
                    FROM perch2_blog_categories c, perch2_blog_posts_to_categories p2c<br />
                    WHERE c.categoryID=p2c.categoryID<br />
                        AND p2c.postID='22'<br />
</span><span style="color: purple; margin: 0.5em 0; padding-left: 0.5em; border-left: 2px solid silver; display: block;">SELECT * <br />
                FROM perch2_blog_sections ORDER BY sectionTitle ASC<br />
</span><span style="color: purple; margin: 0.5em 0; padding-left: 0.5em; border-left: 2px solid silver; display: block;">SELECT c.*<br />
                    FROM perch2_blog_categories c, perch2_blog_posts_to_categories p2c<br />
                    WHERE c.categoryID=p2c.categoryID<br />
                        AND p2c.postID='21'<br />
</span><span style="color: purple; margin: 0.5em 0; padding-left: 0.5em; border-left: 2px solid silver; display: block;">SELECT c.*<br />
                    FROM perch2_blog_categories c, perch2_blog_posts_to_categories p2c<br />
                    WHERE c.categoryID=p2c.categoryID<br />
                        AND p2c.postID='20'<br />
</span><span style="color: purple; margin: 0.5em 0; padding-left: 0.5em; border-left: 2px solid silver; display: block;">SELECT c.*<br />
                    FROM perch2_blog_categories c, perch2_blog_posts_to_categories p2c<br />
                    WHERE c.categoryID=p2c.categoryID<br />
                        AND p2c.postID='19'<br />
</span>
</div>
Drew McLellan

Drew McLellan 2638 points
Perch Support

The count will be of the main items, not the repeater - is that what you're seeing?

Oh i see, i wrapped the whole lot in a repeater, so could just add another easy, but maybe thats not the best way then. You can only count on the content not the repeater. as my content is all in the repeater its not seen then.

cheers for the help on this drew.

All sorted now I've taken it out the repeater.