iNoize Posted January 15, 2016 Posted January 15, 2016 Hello, i have an call where i select my pages with different parameters. $kundenliste = $pages->find("template=referenz, limit=8, images.count>0, unternehmen.count>=1, sort=random"); unternehmen is an Page tv where I associate the pages to the project. so i get an array of ID's foreach ($kundenliste as $kunden) { echo $kunden->unternehmen."<br>"; } how i can create a new pageArray so that i can loop the id's and get the title , images , headline values from the unternehmen ?? because foreach ($kundenliste as $kunden) { echo $kunden->unternehmen->images->first()->url; } dont really works for me.
LostKobrakai Posted January 15, 2016 Posted January 15, 2016 There's no "creation of a new page array", because $kunden->unternehmen is already the pagearray. It's just converted in a list of id's for stringified output. You can directly loop over the list like so: foreach ($kundenliste as $kunden) { foreach($kunden->unternehmen as $unternehmen){ echo $unternehmen->title; } } 1
hheyne Posted January 16, 2016 Posted January 16, 2016 If you want to get only the first instance of unternehmen you can use $kunden->unternehmen->first. It's all the same as with images.
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