1

Is there a way to search by date in the Article Manager Administrator?

You can search using the text input, but it doesn't allow you to search for dates, only ID, AUTHOR, CONTENT, or a free text.

I need to search the articles at the article manager by their dates (created dates), example: I would like to get all the articles from 2021 and exclude all the rest.

I'm using Joomla 4.4.1

1 Answer 1

1

Searching on dates is not a default functionality in Joomla 4.

The only search options that you have is to search for id:, author:, content:, or free text (which is searched for in the title, alias, and note fields). You can see that in the code https://github.com/joomla/joomla-cms/blob/4.4-dev/administrator/components/com_content/src/Model/ArticlesModel.php line 448:

// Filter by search in title.
        $search = $this->getState('filter.search');

        if (!empty($search)) {
            if (stripos($search, 'id:') === 0) {
                $search = (int) substr($search, 3);
                $query->where($db->quoteName('a.id') . ' = :search')
                    ->bind(':search', $search, ParameterType::INTEGER);
            } elseif (stripos($search, 'author:') === 0) {
                $search = '%' . substr($search, 7) . '%';
                $query->where('(' . $db->quoteName('ua.name') . ' LIKE :search1 OR ' . $db->quoteName('ua.username') . ' LIKE :search2)')
                    ->bind([':search1', ':search2'], $search);
            } elseif (stripos($search, 'content:') === 0) {
                $search = '%' . substr($search, 8) . '%';
                $query->where('(' . $db->quoteName('a.introtext') . ' LIKE :search1 OR ' . $db->quoteName('a.fulltext') . ' LIKE :search2)')
                    ->bind([':search1', ':search2'], $search);
            } else {
                $search = '%' . str_replace(' ', '%', trim($search)) . '%';
                $query->where(
                    '(' . $db->quoteName('a.title') . ' LIKE :search1 OR ' . $db->quoteName('a.alias') . ' LIKE :search2'
                        . ' OR ' . $db->quoteName('a.note') . ' LIKE :search3)'
                )
                    ->bind([':search1', ':search2', ':search3'], $search);
            }
        }

A workaround is to order the articles on date. The ordering filter (not the column header) has options to choose to filter on "Created date" or "Modified date".

1
  • 1
    Thank you for your reply. Sorting by date is ok, but the need to search for a date is different than a sort (obvisouly), let's say you have hundreds of dates, even with a sort you'll have to search for a given date. Maybe the solution is overriding the model and implementing the search by myself.
    – jackJoe
    Jan 8 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.