Feature No Code Attached Yet good first issue
avatar ChristineWk
ChristineWk
24 Jul 2025

Steps to reproduce the issue

As an example from a user:
"How can I change the sorting of the year (appears first 2011 and not 2025")?

It is possible to manipulate the list in a template override ....
(Komponenten -> com_content -> archive)
But it is tedious

Expected result

Hence the request:
There should be a parameter for sorting.
Thank You.

avatar ChristineWk ChristineWk - open - 24 Jul 2025
avatar ChristineWk ChristineWk - change - 24 Jul 2025
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 24 Jul 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 24 Jul 2025
avatar brianteeman
brianteeman - comment - 24 Jul 2025

It already exists

Image
avatar ChristineWk
ChristineWk - comment - 24 Jul 2025

Thank you @brianteeman
Will inform and check it.

avatar drmenzelit
drmenzelit - comment - 24 Jul 2025

The Article Order field changes the order of the articles in the list, not the order of the years in the filter

avatar brianteeman
brianteeman - comment - 24 Jul 2025

Then I misunderstood

avatar brianteeman
brianteeman - comment - 24 Jul 2025

"How can I change the sorting of the year (appears first 2011 and not 2025")?

I just checked and by default the filter appears that way

Image
avatar ChristineWk
ChristineWk - comment - 24 Jul 2025

As mentioned above, it would be possible with an override. An idea from Viktor Vogel's @Kubik-Rubik

Would it be good to be able to implement it?

`<?php $html = $this->form->yearField;

preg_match('/<option value=""[^>]*>' . Text::_('JYEAR') . '</option>/', $html, $placeholderMatch);
preg_match_all('/(\d{4})</option>/', $html, $yearMatches, PREG_SET_ORDER);

$years = [];

foreach ($yearMatches as $match) {
$years[] = [
'value' => $match[1],
'html' => $match[0],
];
}

usort($years, fn($a, $b) => $b['value'] <=> $a['value']);

$placeholder = $placeholderMatch[0] ?? '';
$optionsSorted = array_map(fn($y) => $y['html'], $years);

$selectYear = '' . "\n"; $selectYear .= ' ' . $placeholder . "\n"; $selectYear .= ' ' . implode("\n ", $optionsSorted) . "\n"; $selectYear .= '';

echo $selectYear; ?>`

Sorry, I wanted to paste the above into a code field...

avatar ChristineWk
ChristineWk - comment - 24 Jul 2025

Info from @Kubik-Rubik

If you want to implement this correctly in the core, you either have to intervene in the HtmlView (components/com_content/src/View/Archive/HtmlView.php) or, even better, in the corresponding model for the years (\Joomla\Component\Content\Site\Model\ArchiveModel::getYears)

avatar brianteeman
brianteeman - comment - 24 Jul 2025

if @Kubik-Rubik wants to submit a PR then he should do that.

avatar chmst chmst - change - 25 Jul 2025
Labels Added: Feature good first issue
avatar chmst chmst - labeled - 25 Jul 2025
avatar chmst chmst - labeled - 25 Jul 2025
avatar Klath123
Klath123 - comment - 27 Jul 2025

Hey 👋 can I work on this issue

avatar chmst
chmst - comment - 28 Jul 2025

@Klath123 sure, you are welcome :) We do not assign issues, everyone can make a PR.

Add a Comment

Login with GitHub to post a comment