0

i have developed a component for Joomla 3, and i know that i can perform operations of the table form on save with the prepareTable function in the /administrator/components/com_edm/models/edm.php class

however now i need to manipulate the DB for when users delete a record of my component in the backend.

essentially i am asking if there is a function like prepareTable but for deletion

Thanks in advance

Daniel
  • 1

1 Answers1

0

OK...after much research i have found a way to achieve what i want.

alter the administrator/components/com_edm/views/newsletterss/view.html.php file to register your new button function like so JToolBarHelper::trash('newsletterss.Mytrash', 'JTOOLBAR_TRASH');

and then extend the controller for the component list

administrator/components/com_edm/controllers/newsletterss.php where you can set your own function like so

public function Mytrash(){

    // Check for request forgeries
    JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));

    // Get items to remove from the request.
    $cid = JRequest::getVar('cid', array(), '', 'array');

    if (!is_array($cid) || count($cid) < 1)
    {
        JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED'));
    }
    else
    {
        // Get the model.
        $model = $this->getModel();

        // Make sure the item ids are integers
        jimport('joomla.utilities.arrayhelper');
        JArrayHelper::toInteger($cid);

        // Remove the items.
        if ($model->delete($cid))
        {
            $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
        }
        else
        {
            $this->setMessage($model->getError());
        }
    }

    $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
}
Daniel
  • 1