Skip to content
Merged
2 changes: 2 additions & 0 deletions administrator/language/en-GB/com_content.ini
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ COM_CONTENT_FIELD_URLS_OPTIONS="URL Options"
COM_CONTENT_FIELD_URLSPOSITION_LABEL="Positioning of the Links"
COM_CONTENT_FIELD_VALUE_USE_ARTICLE_SETTINGS="Use Article Settings"
COM_CONTENT_FIELD_VERSION_LABEL="Revision"
COM_CONTENT_FIELD_YEAR_SORT_DESC="The order in which years will appear in the year sort dropdown. Oldest First shows years in ascending order (2011, 2012...). Most Recent First shows years in descending order (2025, 2024...)."
COM_CONTENT_FIELD_YEAR_SORT_LABEL="Year Sort Order"
COM_CONTENT_FIELDS_ARTICLE_FIELD_ADD_TITLE="Articles: New Field"
COM_CONTENT_FIELDS_ARTICLE_FIELD_EDIT_TITLE="Articles: Edit Field"
COM_CONTENT_FIELDS_ARTICLE_FIELDS_TITLE="Articles: Fields"
Expand Down
13 changes: 7 additions & 6 deletions components/com_content/src/Model/ArchiveModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,12 @@ public function getData()
*/
public function getYears()
{
$db = $this->getDatabase();
$nowDate = Factory::getDate()->toSql();
$query = $db->getQuery(true);
$queryDate = QueryHelper::getQueryDate($this->state->params->get('order_date'), $db);
$years = $query->year($queryDate);
$db = $this->getDatabase();
$nowDate = Factory::getDate()->toSql();
$query = $db->getQuery(true);
$queryDate = QueryHelper::getQueryDate($this->state->params->get('order_date'), $db);
$years = $query->year($queryDate);
$yearSort = $this->state->params->get('year_sort_order', 'ASC');

$query->select('DISTINCT ' . $years)
->from($db->quoteName('#__content', 'a'))
Expand All @@ -182,7 +183,7 @@ public function getYears()
)
->bind(':publishUp', $nowDate)
->bind(':publishDown', $nowDate)
->order('1 ASC');
->order('1 ' . $yearSort);

$db->setQuery($query);

Expand Down
12 changes: 12 additions & 0 deletions components/com_content/tmpl/archive/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@
<option value="published">JPUBLISHED</option>
</field>

<field
name="year_sort_order"
type="list"
label="COM_CONTENT_FIELD_YEAR_SORT_LABEL"
description="COM_CONTENT_FIELD_YEAR_SORT_DESC"
default="ASC"
validate="options"
>
<option value="ASC">JGLOBAL_OLDEST_FIRST</option>
<option value="DESC">JGLOBAL_MOST_RECENT_FIRST</option>
</field>

<field
name="display_num"
type="list"
Expand Down
Loading