2

The Trash button isn't working properly in a custom component in Joomla 3.x. It's behaving a bit weirdly. What happened when I tried to select a particular file or file list and then click the Trash button and that particular file or file list is still showing there (it supposed to move from the original location to the trashed box location when we hit the trash button, but here it stays in both location). And in the same time that particular file or file list also can be seen to the Trashed box as well where I just need to select that file and click the Empty Trash button. Empty Trash button is working fine.

The problem is that the file is showing in both location after click Trash button. It's look like some code is missing in this custom component and that's why the Trash button isn't working the way it should worked.

The only code I found related to this is the following:

if ($this->state->get('filter.state') == -2 && $canDo->get('core.delete'))
{
    JToolbarHelper::deleteList('', 'kpcnews.delete', 'JTOOLBAR_EMPTY_TRASH');
}       
elseif ($canDo->get('core.edit.state'))
{
    JToolbarHelper::trash('kpcnews.trash');
}
1
  • Could you try going to the Joomla Article Manager (com_content), create a new article, save it, then move it to the trash. Can you also see this trashed article in the normal list?
    – Lodder
    Commented Jul 28, 2016 at 14:00

1 Answer 1

2

The code you are showing is responsible for showing either the delete or the trash button, based on your current selected state filter.

If you are following Joomla's coding architecture, the code you are looking for is located in your list models getListQuery method. There is a part which handles the filtering by state, for example:

// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
    $query->where($db->quoteName('a.state') . ' = ' . (int) $published);
}
elseif ($published === '')
{
    $query->where($db->quoteName('a.state') . ' IN (0, 1)');
}

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.