diff --git a/components/Collection/templates/collection/actors.html.twig b/components/Collection/templates/collection/actors.html.twig
index d9f9b8e1b9..26c2202ed9 100644
--- a/components/Collection/templates/collection/actors.html.twig
+++ b/components/Collection/templates/collection/actors.html.twig
@@ -8,9 +8,14 @@
{% trans %}Sort by:{% endtrans %}
- {% for option in sort_options %}
-
{{ option.label }}
- {% endfor %}
+
diff --git a/plugins/Directory/Controller/Directory.php b/plugins/Directory/Controller/Directory.php
index 550529658f..d0112b3f68 100644
--- a/plugins/Directory/Controller/Directory.php
+++ b/plugins/Directory/Controller/Directory.php
@@ -31,7 +31,7 @@ use App\Util\Exception\ClientException;
use Component\Collection\Util\Controller\CircleController;
use Symfony\Component\HttpFoundation\Request;
-class Directory extends FeedController
+class Directory extends CircleController
{
public const PER_PAGE = 32;
public const ALLOWED_FIELDS = ['nickname', 'created', 'modified', 'activity', 'subscribers'];
@@ -62,7 +62,11 @@ class Directory extends FeedController
$order_by_op = 'ASC';
} else {
$order_by_field = $order_by_qs;
- $order_by_op = 'ASC';
+ $order_by_op = match ($this->string('order_op')) {
+ 'ASC' => 'ASC',
+ 'DESC' => 'DESC',
+ default => 'ASC',
+ };
}
if (!\in_array($order_by_field, self::ALLOWED_FIELDS)) {
@@ -129,27 +133,22 @@ class Directory extends FeedController
};
// -------- *** --------
- $sort_options = [];
+ $sort_form_fields = [];
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)]),
+ $sort_form_fields[] = [
+ 'checked' => $order_by_field === $al,
+ 'value' => $al,
+ 'label' => _m(ucfirst($al)),
];
}
return [
- '_template' => 'collection/actors.html.twig',
- 'actors' => $query_fn($actor_type),
- 'title' => $title,
- 'empty_message' => $empty_message,
- 'sort_options' => $sort_options,
- 'page' => $page,
+ '_template' => 'collection/actors.html.twig',
+ 'actors' => $query_fn($actor_type),
+ 'title' => $title,
+ 'empty_message' => $empty_message,
+ 'sort_form_fields' => $sort_form_fields,
+ 'page' => $page,
];
}