I want to add a new state to the article list filter on the search tool. The dropdown, has the states, Published, Unpublished, Archived, etc.

How do I add another state to the dropdown? Is there some file I have to change to achieve that?

I have found the file filters.php in the path layouts/joomla/searchtools/default.

But it only has an array with the filters, but where does theses values come from?

$data = $displayData;

// Load the form filters
$filters = $data['view']->filterForm->getGroup('filter');
<?php if ($filters) : ?>
    <?php foreach ($filters as $fieldName => $field) : ?>
        <?php if ($fieldName != 'filter_search') : ?>
            <div class="js-stools-field-filter">
                <?php echo $field->input; ?>
        <?php endif; ?>
    <?php endforeach; ?>
<?php endif; ?>

Values are in coming from field type status in file administrator/components/com_content/models/forms/filter_articles.xml.

This field looks like this

    <option value="">JOPTION_SELECT_PUBLISHED</option>

If you add more option tags, it will show up. But this is core file, so it's strongly not recommended to edit this.

You should safely override this file, so if you update Joomla!, it won't be overwritten.

See discussion on Joomla! forum: Overriding Form Field XML?.

And Form XML Override extension should help.

Also, if you add new state, you should add it to edit view too. Edit view form XML is in same folder: administrator/components/com_content/models/forms/article.xml.

This state gets store in database field type tinyint(3), so your option value should regard this.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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