joer80 Posted February 10, 2015 Posted February 10, 2015 Is it possible to grab a field in the first repeater group without looping through it? ie. instead of foreach($page->ThisRepeater as $m) { echo $m->h1; } Something like this: $page->ThisRepeater[0]->h1 or $page->ThisRepeater->first()->h1 Thanks!
joer80 Posted February 10, 2015 Author Posted February 10, 2015 Ha, think I guessed right. This seems to work: echo $page->ThisRepeater[0]->h1; Nevermind! 1
LostKobrakai Posted February 10, 2015 Posted February 10, 2015 The api way would be not using array notation but one of these. $page->repeater->first(); $page->repeater->eq($i); $page->repeater->last(); 2
joer80 Posted February 10, 2015 Author Posted February 10, 2015 Great! I will give that a try! So this should work? echo $page->ThisRepeater->first()->h1;
joer80 Posted February 11, 2015 Author Posted February 11, 2015 They both work! Thanks for the tip! 1
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