disall2000 Posted March 12, 2018 Share Posted March 12, 2018 I'm very new to both Processwire and PHP so bare with me. Now I've set up everything in the different Fields, Pages and Templates. In one of the templates I have created a Repeater Field containing one Field that is a Page Reference and another Field that is a Text Field. Now I've tried both foreach ($page->template->fieldgroup as $f) { echo $f->name . "<br>"; } and <?php echo $page->get("myfieldgroup"); ?> Here I get the ID's from the Page Reference but nothing from the Text Field. The first example gave me nothing at all. So how do fetch these results? Link to comment Share on other sites More sharing options...
Sergio Posted March 12, 2018 Share Posted March 12, 2018 (edited) You can access a repeater field directly by its name, no need to use $page->template.. So, to get a title field inside a repeater, you just need: $repeater = $page->your_repeater_name; foreach( $repeater as $rep ) { echo $rep->text_field_name; echo $rep->page_reference_field_name->title; //output the title of the page that's referenced } Edited March 12, 2018 by Sergio submitted without code 1 Link to comment Share on other sites More sharing options...
BitPoet Posted March 12, 2018 Share Posted March 12, 2018 You treat the repeater like any other field. <?php foreach($page->repeaterfield as $rep) { echo "<p>{$rep->pagereffield->title}</p>\n"; echo "<p>{$rep->textfield}</p>\n"; } $page->repeaterfield (like $page->get("myfieldgroup") in your example) will get you the repeater field itself, and in string context, return the IDs of its individual repeater elements. 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