/ / Wie kann ich die Spalten meiner Tabelle mit einem Schlüsselwort bestellen? - PHP, HTML, Zweig

Wie kann ich die Spalten meiner Tabelle mit einem Schlüsselwort bestellen? - PHP, HTML, Zweig

Meine Spalte ist momentan {article, formation , tous article , tous formation, notif, offre}. Ich möchte es in dieser Reihenfolge machen {article, tous articles , espace&nbsp, formation , tous formation , &nbsp, notif , offre}

Das ist mein Code, der td benannt: ban.page

<table id="liste-offresemploi" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th width="5">#</th>
<th>Titre 1</th>
<th>Type</th>
<th>Page</th>
<th>pagetest</th>
<th width="20">Statut</th>
<th>URL</th>
<th width="5"></th>
<th width="5" class="header"></th>
</tr>
</thead>
<tbody>
{% if nb_bannieres > 0 %}

{% for bann in bannieres %}
<tr>
<td>{{ bann.idbanniereinterne }}</td>
<td>{{ bann.titre }}</td>
<td>{% if bann.type == 2 %} Publicité {% else %} {% if bann.type == 1 %} Structure {% endif %} {% endif %}</td>
<td id="tri">{{bann.page }}</td>
<td>{% if bann.page == "articles" %} 0 {% else %} {% if bann.page == "toutarticles" %} 1 {% endif %} {% endif %}  </td>
<td><a href="#?" class="toogleactif" name="banniereinterne-{{ bann.idbanniereinterne }}" rel="{% if bann.actif %}0{% else %}1{% endif %}">
{% if bann.actif %}
<button class="btn btn-success actifjs">Actif</button>
{% else %}
<button class="btn btn-warning actifjs">Non Actif</button>
{% endif %}
</a>
</td>
<td>{{ bann.url }}</td>
<td><span class="glyphicon glyphicon-edit btnadmin btnedit" title="Editer" rel="table_banniereinterne|id_{{ bann.idbanniereinterne }}"></span></td>
<td><span class="glyphicon glyphicon-trash btnadmin deladmin" title="Supprimer" rel="{{ bann.idbanniereinterne }}|banniereinterne|0"></span></td>
</tr>

Antworten:

0 für die Antwort № 1

Eine einfache Lösung besteht darin, Ihrer Entität ein Feld hinzuzufügen order (Geben Sie int ein) und geben Sie den Bestellwert an

Category     | Order
------------ | ------
article      | 2
formation    | 3
tous article | 1

Und dann bestelle in deinem query dadurch Order Säule ASC und du wirst es bekommen

tous article
article
formation