Purple Posted June 17 Share Posted June 17 (edited) Hey all ! Can't seem to find any other topics answering my question. My website as 5 categories, with up to 4 children each. My homepage has a grid where I want to return all images from children of all categories, but in the folowing order : all first children, then all second, then all third.. Now the only way I can structure this is : foreach category{ child = category->children() foreach child(limit=1 start=1){ echo children ->image; }} but I'd have to repeat that for any maximum number of children. Any other ways ? Edited June 17 by Purple Link to comment Share on other sites More sharing options...
ngrmm Posted June 18 Share Posted June 18 @Purple your question is more related to php as to processwire. You better search in stackoverflow for these kind of question. Anyway, you could use a for loop. This code gives you the first images of the first five category children. for ($i = 0; $i <= 4; $i++) { foreach($categories as $category) { $image = $category->children->eq($i)->images->first; } } 1 Link to comment Share on other sites More sharing options...
Purple Posted June 18 Author Share Posted June 18 Hey @ngrmm ! Thank you that helps ? 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