Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在自定义组件的Joomla前端中使用JToolbar或JToolbarHelper for CRUD_Php_Joomla_Joomla3.3 - Fatal编程技术网

Php 在自定义组件的Joomla前端中使用JToolbar或JToolbarHelper for CRUD

Php 在自定义组件的Joomla前端中使用JToolbar或JToolbarHelper for CRUD,php,joomla,joomla3.3,Php,Joomla,Joomla3.3,这些课程适用于哪些情况?我一直在尝试使用这两种方法,但都不起作用。 组件框架已经生成,管理员端有CRUD操作。我尝试从生成的代码中使用JToolbarHelper,如mycomponent/view.html.php中所示: // Overwriting JView display method function display($tpl = null) { // Include helper submenu InvoiceHelper::addSubmenu('invoice'

这些课程适用于哪些情况?我一直在尝试使用这两种方法,但都不起作用。 组件框架已经生成,管理员端有CRUD操作。我尝试从生成的代码中使用JToolbarHelper,如mycomponent/view.html.php中所示:

// Overwriting JView display method
function display($tpl = null)
{
    // Include helper submenu
    InvoiceHelper::addSubmenu('invoice');

    // Assign data to the view
    $this->items = $this->get('Items');
    $this->pagination = $this->get('Pagination');

    // Check for errors.
    if (count($errors = $this->get('Errors'))){
        JError::raiseError(500, implode('<br />', $errors));
        return false;
    };

    // Set the toolbar
    $this->addToolBar();
    // Show sidebar
    $this->sidebar = JHtmlSidebar::render();

    // Display the view
    parent::display($tpl);
}

protected function addToolBar()
{
    JLoader::register('JToolbarHelper', JPATH_ADMINISTRATOR.'/includes/toolbar.php');

    $canDo = InvoiceHelper::getActions();
    JToolBarHelper::title(JText::_('Invoice Manager'), 'invoice');
    if($canDo->get('core.create')){
        JToolBarHelper::addNew('invoic.add', 'JTOOLBAR_NEW');
    };
    if($canDo->get('core.edit')){
        JToolBarHelper::editList('invoic.edit', 'JTOOLBAR_EDIT');
    };
    if($canDo->get('core.delete')){
        JToolBarHelper::deleteList('', 'invoice.delete', 'JTOOLBAR_DELETE');
    };
 }
//覆盖JView显示方法
函数显示($tpl=null)
{
//包含辅助程序子菜单
发票助手::添加子菜单(“发票”);
//将数据指定给视图
$this->items=$this->get('items');
$this->pagination=$this->get('pagination');
//检查错误。
如果(计数($errors=$this->get('errors')){
JError::raiseError(500,内爆(“
,$errors”); 返回false; }; //设置工具栏 $this->addToolBar(); //显示边栏 $this->sidebar=JHtmlSidebar::render(); //显示视图 父::显示($tpl); } 受保护的函数addToolBar() { JLoader::register('JToolbarHelper',JPATH_ADMINISTRATOR.'/includes/toolbar.php'); $canDo=InvoiceHelper::getActions(); JToolBarHelper::title(JText::((“发票管理器”),“发票”); 如果($canDo->get('core.create')){ JToolBarHelper::addNew('invoic.add','JTOOLBAR_NEW'); }; 如果($canDo->get('core.edit')){ JToolBarHelper::editList('invoic.edit','JTOOLBAR_edit'); }; if($canDo->get('core.delete')){ JToolBarHelper::deleteList(“”,'invoice.delete','JTOOLBAR_delete'); }; }
但它甚至没有出现在页面上

然后我看到了这个教程,它有点有用,只是我无法想象实现一个实体列表,每个实体都有复选框和操作。我不清楚如何使用这种方法处理表单提交,好像是通过JS实现的,我做对了吗


那么,请告诉我,有什么区别,为什么第一种方法甚至没有使工具栏出现?

我知道这是很久以前的事了,但我一直在寻找相同的结果,并发现以下内容可以加载页面上的工具栏。使用上述代码:

protected function addToolBar()
{
    JLoader::register('JToolbarHelper', JPATH_ADMINISTRATOR.'/includes/toolbar.php');

    $canDo = InvoiceHelper::getActions();
    JToolBarHelper::title(JText::_('Invoice Manager'), 'invoice');
    if($canDo->get('core.create')){
        JToolBarHelper::addNew('invoic.add', 'JTOOLBAR_NEW');
    }
    if($canDo->get('core.edit')){
        JToolBarHelper::editList('invoic.edit', 'JTOOLBAR_EDIT');
    }
    if($canDo->get('core.delete')){
        JToolBarHelper::deleteList('', 'invoice.delete', 'JTOOLBAR_DELETE');
    }
    $this->toolbar = JToolbar::getInstance(); // <<<---------- ADD THIS TO METHOD!
 }
受保护的函数addToolBar()
{
JLoader::register('JToolbarHelper',JPATH_ADMINISTRATOR.'/includes/toolbar.php');
$canDo=InvoiceHelper::getActions();
JToolBarHelper::title(JText::((“发票管理器”),“发票”);
如果($canDo->get('core.create')){
JToolBarHelper::addNew('invoic.add','JTOOLBAR_NEW');
}
如果($canDo->get('core.edit')){
JToolBarHelper::editList('invoic.edit','JTOOLBAR_edit');
}
if($canDo->get('core.delete')){
JToolBarHelper::deleteList(“”,'invoice.delete','JTOOLBAR_delete');
}

$this->toolbar=JToolbar::getInstance();//您不能在前端使用JToolbar,如果查看代码,您将看到它检查isAdmin()。为什么不呢?简单的JToolbar加上几个按钮就行了,我遵循了上面提到的官方文档中的教程。我只是想知道在使用这种方法进行进一步开发时是否会遇到任何无法解决的问题。这是Joomla 1.0的历史。我曾经尝试过更改它,但它破坏了许多扩展。需要有人来解决编写一个新的包,它可以在任何地方工作。
<?php echo $this->toolbar->render(); ?>