1

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; ?>
            </div>
        <?php endif; ?>
    <?php endforeach; ?>
<?php endif; ?>
1

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

This field looks like this

<field
    name="published"
    type="status"
    label="COM_CONTENT_FILTER_PUBLISHED"
    description="COM_CONTENT_FILTER_PUBLISHED_DESC"
    onchange="this.form.submit();"
    >
    <option value="">JOPTION_SELECT_PUBLISHED</option>
</field>

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.