douduan6731 2013-02-02 22:47 采纳率: 0%
浏览 21

Symfony Twig For Loop

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!

  • 写回答

2条回答 默认 最新

  • duanhuoyao7011 2013-02-02 23:01
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?