samedi 27 juin 2015

ManyOnOne in a twig template

I have the following tables (and entities in / ):

+------------------+                  +--------------------+
|  forum_sections  |                  |  forum_categories  |
+------------------+                  +--------------------+
| id               ├--------|         | id                 |
| title            |        |---------| section            |
| position         |                  | position           |
| created_at       |                  | title              |
+------------------+                  | description        |
                                      +--------------------+

I want to archive the following html page (without the bullets ofcource):

  • this is a title (from forum_sections->title)
    • forum 1 (from forum_categories->title)
    • forum 2 (from forum_categories->title)
  • this is another title (from forum_sections->title)
    • forum 3 (from forum_categories->title)

I did some research on how to do this. So far I tried the following in my twig layout:

{% for section in sections %}
    <h1>title</h1>

    {% for category in categories %}
        bla bla
    {% endfor %}
{% endfor %}

Is this even possible with a 'findAll' query in Doctrine2? I tried some combinations, but they seem to get all the boards ignoring the sections.

Aucun commentaire:

Enregistrer un commentaire