Regrouper les résultats d'une requête suivant un champ
Bonjour,
Je fais cette requête dans mon controlleur :
Code:
1 2 3
| $em = $this->getDoctrine()->getEntityManager();
$media = $em->getRepository('AppMediaBundle:Media')->findByIdPoi($id); |
j'ai mes résultats sur la vue :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| <table class="records_list">
<thead>
<tr>
<th>Id</th>
<th>Title</th>
<th>Type</th>
<th>File</th>
<th>Comment</th>
<th>Partie</th>
</tr>
</thead>
<tbody>
{% for media in media %}
<tr>
<td>{{ media.id}}</td>
<td>{{ media.title }}</td>
<td>{{ media.type }}</td>
<td>{{ media.file }}</td>
<td>{{ media.comment }}</td>
<td>{{ media.partie }}</td>
<td>
{% endfor %}
</tbody>
</table> |
J'ai un tableau qui affiche les résultats.
Maintenant je souhaite modifier l'affichage, je veux regrouper mes résultas suivant un même {{ media.partie }} !!
est ce possible sur Twig !!
Merci
[Twig] colspan classé les elements du tableau suivant une colonne
Bonjour,
J'ai un tableau de 3 colonnes et vu que je ne suis pas trop HTML :
J'ai un petit soucis avec Twig j'essaye d'afficher 2 variables classé suivant une colonne : la variable {{ media. partie }}
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| {% for media in medias %}
<tr>
<th colspan ="1"> Partie:{{ media.partie }}</th>
</tr>
<tr>
{% if (media.comment != null) and (media.comment|length > 1) %}
<td>{{ media.comment }}</td>
{% endif %}
{% if (media.file != null) and (media.file|length > 1) %}
<td>{{ media.file }}</td>
</tr>
{% endif %}
{% endfor %} |
J'ai ceci : une répétition de {{ media.partie }}
Partie:1
commentaire1
fichier1
Partie:1
commentaire2
fichier2
Partie:1
commentaire3
fichier3
.....
au lieu d'avoir :
Partie:1
commentaire1
fichier1
commentaire2
fichier2
commentaire3
fichier3
.....
Quelqu'un peut m'aider !!
Merci