[UI][PLUGIN][Directory] Add sort options to UI

This commit is contained in:
Hugo Sales 2022-01-01 22:17:26 +00:00
parent 5662210a2d
commit d6cd33019d
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 22 additions and 0 deletions

View File

@ -129,11 +129,26 @@ class Directory extends FeedController
};
// -------- *** --------
$sort_options = [];
foreach (self::ALLOWED_FIELDS as $al) {
$sort_options[] = [
'active' => false,
'url' => '?order_by=' . $al . '^',
'label' => _m('{order_by} ascending', ['{order_by}' => ucfirst($al)]),
];
$sort_options[] = [
'active' => false,
'url' => '?order_by=' . $al . 'v',
'label' => _m('{order_by} descending', ['{order_by}' => ucfirst($al)]),
];
}
return [
'_template' => 'directory/actors.html.twig',
'actors' => $query_fn($actor_type),
'title' => $title,
'empty_message' => $empty_message,
'sort_options' => $sort_options,
'page' => $page,
];
}

View File

@ -6,6 +6,13 @@
<section class="section-widget section-padding">
<h2 class="section-title">{{ title }}</h2>
<div>
<p>{% trans %}Sort by:{% endtrans %}</p>
{% for option in sort_options %}
<a {{ option.active ? 'class="active"' : '' }} href="{{ option.url }}">{{ option.label }}</a>
{% endfor %}
</div>
<div class="section-padding">
{% if actors is defined and actors is not empty %}
{% for actor in actors %}