I need to restructure the channel entries (I'm trying to group them by one of the channel fields). For example, say I have a list of fruits and each fruit had a color. I'm trying to group these fruits in an associative array by color, like:
$fruits['yellow'] = array('fruit_name' => 'banana' ...
Once I have this restructured data, I then need to loop over it and output certain mark up.
So far, what I have done is to set
Allow PHP? to
Yes and declared an array, built that array within the entries tag pair, and now going to loop through that array and output the markup I need.
This seems messy. Is there a "cleaner" approach?
This is how I want to output the data, which I think would be impossible to achieve with an
So, I need to loop over the colors, then loop over the fruits within each color. It's a nested array that I need. Using orderby does not give me a nested array.