buster808 Posted April 27, 2019 Share Posted April 27, 2019 Hi, I can view repeater content with a simple foreach loop. Can a limit be added with pagination to a repeater field? Some help in the right direction would be great. Thanks foreach($page->feedback_repeat as $feed ) { $content .= "<h2>{$feed->title}</h2>"; $content .= "<p>{$feed->feedback_body}</p>"; } Link to comment Share on other sites More sharing options...
Zeka Posted April 27, 2019 Share Posted April 27, 2019 $results = $pages->find('template=repeater_your_repeater_field, limit=10'); $content = $results->each(function($item) { $out = "<h2>{$item->title}</h2>"; $out .= "<p>{$item->title}</p>"; return $out; }); $pagination = $results->renderPager(); d($content); d($pagination); 3 Link to comment Share on other sites More sharing options...
Robin S Posted April 28, 2019 Share Posted April 28, 2019 11 hours ago, Zeka said: $results = $pages->find('template=repeater_your_repeater_field, limit=10'); It's not quite that simple for a few reasons. Repeater pages are not directly accessible for non-superusers meaning that selector won't work for guests. So you'd need to specify "include=all", but then you'd also need to exclude any unpublished or "ready" repeater pages with "status!=unpublished". Also, the selector would match all repeater items from that field from all pages, when probably what is wanted is only items from one page. So then you'd need to match repeater pages under only one parent, maybe by building the name of the parent from "for-page-" plus the ID of the page you want the repeater items from. But the simplest way and only marginally less efficient is to match by the IDs of the repeater pages in the field value: $results = $pages->find("id=$page->feedback_repeat, include=all, limit=10"); 4 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now