【问题标题】:Joomla, component, run script on deletion of record from backendJoomla,组件,在从后端删除记录时运行脚本
【发布时间】:2015-05-22 07:39:01
【问题描述】:

我已经为 Joomla 3 开发了一个组件,并且我知道我可以使用 /administrator/components/com_edm/models/edm.php 类中的 prepareTable 函数在保存时执行表格形式的操作

但是现在我需要在用户在后端删除我的组件记录时操作数据库。

基本上我是在问是否有像 prepareTable 这样的功能但要删除

提前致谢

【问题讨论】:

    标签: php joomla3.0 joomla-component


    【解决方案1】:

    好的...经过大量研究,我找到了实现我想要的方法。

    改变 管理员/组件/com_edm/views/newsletterss/view.html.php 像这样注册新按钮功能的文件 JToolBarHelper::trash('newsletterss.Mytrash', 'JTOOLBAR_​​TRASH');

    然后为组件列表扩展控制器

    管理员/组件/com_edm/controllers/newsletterss.php 您可以在其中设置自己的功能

    公共函数 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));
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-06
      • 1970-01-01
      • 2015-09-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多