Skip to content

Commit

Permalink
archived date filter
Browse files Browse the repository at this point in the history
  • Loading branch information
alikon committed Aug 25, 2022
1 parent 3074a99 commit f10bb76
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions components/com_content/src/Model/ArchiveModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,27 +161,28 @@ public function getData()
*/
public function getYears()
{
$db = $this->getDatabase();
$nowDate = Factory::getDate()->toSql();
$query = $db->getQuery(true);
$years = $query->year($db->quoteName('c.created'));
$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);

$query->select('DISTINCT ' . $years)
->from($db->quoteName('#__content', 'c'))
->where($db->quoteName('c.state') . ' = ' . ContentComponent::CONDITION_ARCHIVED)
->from($db->quoteName('#__content', 'a'))
->where($db->quoteName('a.state') . ' = ' . ContentComponent::CONDITION_ARCHIVED)
->extendWhere(
'AND',
[
$db->quoteName('c.publish_up') . ' IS NULL',
$db->quoteName('c.publish_up') . ' <= :publishUp',
$db->quoteName('a.publish_up') . ' IS NULL',
$db->quoteName('a.publish_up') . ' <= :publishUp',
],
'OR'
)
->extendWhere(
'AND',
[
$db->quoteName('c.publish_down') . ' IS NULL',
$db->quoteName('c.publish_down') . ' >= :publishDown',
$db->quoteName('a.publish_down') . ' IS NULL',
$db->quoteName('a.publish_down') . ' >= :publishDown',
],
'OR'
)
Expand Down

0 comments on commit f10bb76

Please sign in to comment.