Hi I have a three column layout like the following:
<div class="container">
<div id="col1">
</div>
<div id="col2">
</div>
<div id="col3">
</div>
<div>
So I have data that I want to fill in the columns using a the for loop in twig. I couldn't think of a way to do this except to pass the data for each column into an array for each column in the controller and pass it to the view then loop though each array.
I'm relativly new to both PHP and Symfony and I think I am over/under thinking this. I don't want anyone to do the work for me , just an idea in the right direction.
Thanks!
What you said is the best practise for this. But instead of the second array, an object is usually used.
I don't know what data your are talking about and how you get that data. But it is likely that you get those from a database. Did you read the Doctrine article in the book? They show you how you can handle things like this.
I guess the data is split between columns following conditions. You should try to apply those conditions in your controller and send 3 arrays to twig. It would help if you explained more (maybe with some code) about the db and the query.