How can I order the columns of a table using a keyword?

In my column now {article, formation , tous article , tous formation, notif, offre}

. I want to do it in this order{article, tous articles , espace&nbsp, formation , tous formation , &nbsp, notif , offre}

This is my code, td

has a name: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>

      

+3


source to share


1 answer


A simple solution is to add a field order

(int type) to your object and assign an order value

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

      



And then order in your by query

this column order

ASC

and you get

tous article
article
formation

      

0


source







All Articles