Files
slim-blog/views/admin/categories/index.twig
2026-03-16 01:47:07 +01:00

73 lines
2.5 KiB
Twig
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends "layout.twig" %}
{% block title %}Tableau de bord Catégories{% endblock %}
{% block content %}
<h2>Gestion des catégories</h2>
{% include 'partials/_admin_nav.twig' %}
{% if error %}
<div class="alert alert--danger">{{ error }}</div>
{% endif %}
{% if success %}
<div class="alert alert--success">{{ success }}</div>
{% endif %}
<div class="category-create">
<h3 class="category-create__title">Ajouter une catégorie</h3>
<form method="post" action="/admin/categories/create" class="category-create__form">
<input type="hidden" name="{{ csrf.keys.name }}" value="{{ csrf.name }}">
<input type="hidden" name="{{ csrf.keys.value }}" value="{{ csrf.value }}">
<label for="name" class="category-create__label">
Nom
<input type="text" id="name" name="name" required maxlength="100"
class="form-container__input category-create__input" placeholder="ex : Développement Web">
</label>
<button type="submit" class="btn btn--primary">Créer</button>
</form>
<p class="category-create__hint">Le slug URL est généré automatiquement depuis le nom.</p>
</div>
{% if categories is not empty %}
<table class="admin-table">
<thead>
<tr>
<th>Nom</th>
<th>Slug</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for category in categories %}
<tr>
<td data-label="Nom"><strong>{{ category.name }}</strong></td>
<td data-label="Slug"><code>{{ category.slug }}</code></td>
<td data-label="Actions">
<div class="u-inline-actions">
<form method="post" action="/admin/categories/delete/{{ category.id }}" class="u-inline-form">
<input type="hidden" name="{{ csrf.keys.name }}" value="{{ csrf.name }}">
<input type="hidden" name="{{ csrf.keys.value }}" value="{{ csrf.value }}">
<button type="submit" class="btn btn--sm btn--danger"
onclick="return confirm('Supprimer la catégorie « {{ category.name }} » ?
Cette action est impossible si des articles lui sont rattachés.')">
Supprimer
</button>
</form>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p><em>Aucune catégorie créée.</em></p>
{% endif %}
{% endblock %}