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
Joomla 没有管理菜单的组件_Joomla_Joomla1.5_Joomla Extensions_Joomla2.5 - Fatal编程技术网

Joomla 没有管理菜单的组件

Joomla 没有管理菜单的组件,joomla,joomla1.5,joomla-extensions,joomla2.5,Joomla,Joomla1.5,Joomla Extensions,Joomla2.5,有人知道如何创建一个Joomla组件,而不在“管理”菜单中创建节吗 我已删除清单中的所有菜单项,但它仍会创建一个管理菜单项: <administration> <files folder="admin"> <filename>index.html</filename> <filename>gallery.php</filenam

有人知道如何创建一个Joomla组件,而不在“管理”菜单中创建节吗

我已删除清单中的所有菜单项,但它仍会创建一个管理菜单项:

<administration>
            <files folder="admin">
                    <filename>index.html</filename>
                    <filename>gallery.php</filename>
                    <filename>controller.php</filename>
                    <folder>views</folder>
                    <folder>models</folder>
            </files>
</administration>

index.html
gallery.php
controller.php
意见
模型
有什么想法吗


注意:这是关于J2.5的,但1.5也很有趣。

Joomla将在安装时自动插入这些菜单项,但如果您真的愿意,可以通过各种方式删除它们

最简单的方法是更改菜单表中组件行的
client\u id
字段。管理员菜单项具有
client\u id=1
,但是如果您将其更改为类似
client\u id=10
之类的废话,它们将不会显示在管理员站点中

或者,您可以直接删除它们。由于菜单表使用嵌套集模型,因此不应仅删除该行。您最好使用
MenusModelMenu
类的delete函数


如果您的安装程序包含一个带有
postflight
功能的脚本,则可以在组件安装过程中执行上述任一操作。

Joomla将在安装时自动插入这些菜单项,但如果您真的想这样做,您可以通过各种方式删除它们

最简单的方法是更改菜单表中组件行的
client\u id
字段。管理员菜单项具有
client\u id=1
,但是如果您将其更改为类似
client\u id=10
之类的废话,它们将不会显示在管理员站点中

或者,您可以直接删除它们。由于菜单表使用嵌套集模型,因此不应仅删除该行。您最好使用
MenusModelMenu
类的delete函数


如果您的安装程序包含带有
postfiright
功能的脚本,则可以在组件安装过程中执行上述任一操作。

这是我最后用来删除“管理”菜单项的代码

首先,我创建了一个安装脚本,该脚本在一个名为script.php的文件中实现了飞行后方法:

<?php
//No direct access
defined('_JEXEC) or die;');

class com_mycomponentInstallerScript{
    function postflight($type, $parent){
        // $parent is the class calling this method
    // $type is the type of change (install, update or discover_install)
        $componentName = 'myComponent'; //The name you're using in the manifest
        $extIds = $this->getExtensionIds($componentName);
        if(count($extIds)) {
            foreach($extIds as $id) {
                if(!$this->removeAdminMenus($id)) {
                    echo JText::_(COM_MYCOMPONENT_POSTFLIGHT_FAILED);
                }
            }
        }
    }

    /**
    * Retrieves the #__extensions IDs of a component given the component name (eg "com_somecomponent")
    *
    * @param   string   $component The component's name
    * @return   array   An array of component IDs
    */
    protected function getExtensionIds($component) {
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        $query->select('extension_id');
        $query->from('#__extensions');
        $cleanComponent = filter_var($component, FILTER_SANITIZE_MAGIC_QUOTES);
        $query->where($query->qn('name') . ' = ' . $query->quote($cleanComponent));
        $db->setQuery($query);
        $ids = $db->loadResultArray();
        return $ids;
    }

     /**
   * Removes the admin menu item for a given component
   *
   * This method was pilfered from JInstallerComponent::_removeAdminMenus()
   *
   * @param   int      $id The component's #__extensions id
   * @return   bool   true on success, false on failure
   */
   protected function removeAdminMenus(&$id)
   {
      // Initialise Variables
      $db = JFactory::getDbo();
      $table = JTable::getInstance('menu');
      // Get the ids of the menu items
      $query = $db->getQuery(true);
      $query->select('id');
      $query->from('#__menu');
      $query->where($query->qn('client_id') . ' = 1');
      $query->where($query->qn('component_id') . ' = ' . (int) $id);

      $db->setQuery($query);

      $ids = $db->loadColumn();

      // Check for error
      if ($error = $db->getErrorMsg())
      {
         return false;
      }
      elseif (!empty($ids))
      {
         // Iterate the items to delete each one.
         foreach ($ids as $menuid)
         {
            if (!$table->delete((int) $menuid))
            {
               return false;
            }
         }
         // Rebuild the whole tree
         $table->rebuild();
      }
      return true;
   }

}

这是我最后用来删除管理菜单中条目的代码

首先,我创建了一个安装脚本,该脚本在一个名为script.php的文件中实现了飞行后方法:

<?php
//No direct access
defined('_JEXEC) or die;');

class com_mycomponentInstallerScript{
    function postflight($type, $parent){
        // $parent is the class calling this method
    // $type is the type of change (install, update or discover_install)
        $componentName = 'myComponent'; //The name you're using in the manifest
        $extIds = $this->getExtensionIds($componentName);
        if(count($extIds)) {
            foreach($extIds as $id) {
                if(!$this->removeAdminMenus($id)) {
                    echo JText::_(COM_MYCOMPONENT_POSTFLIGHT_FAILED);
                }
            }
        }
    }

    /**
    * Retrieves the #__extensions IDs of a component given the component name (eg "com_somecomponent")
    *
    * @param   string   $component The component's name
    * @return   array   An array of component IDs
    */
    protected function getExtensionIds($component) {
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        $query->select('extension_id');
        $query->from('#__extensions');
        $cleanComponent = filter_var($component, FILTER_SANITIZE_MAGIC_QUOTES);
        $query->where($query->qn('name') . ' = ' . $query->quote($cleanComponent));
        $db->setQuery($query);
        $ids = $db->loadResultArray();
        return $ids;
    }

     /**
   * Removes the admin menu item for a given component
   *
   * This method was pilfered from JInstallerComponent::_removeAdminMenus()
   *
   * @param   int      $id The component's #__extensions id
   * @return   bool   true on success, false on failure
   */
   protected function removeAdminMenus(&$id)
   {
      // Initialise Variables
      $db = JFactory::getDbo();
      $table = JTable::getInstance('menu');
      // Get the ids of the menu items
      $query = $db->getQuery(true);
      $query->select('id');
      $query->from('#__menu');
      $query->where($query->qn('client_id') . ' = 1');
      $query->where($query->qn('component_id') . ' = ' . (int) $id);

      $db->setQuery($query);

      $ids = $db->loadColumn();

      // Check for error
      if ($error = $db->getErrorMsg())
      {
         return false;
      }
      elseif (!empty($ids))
      {
         // Iterate the items to delete each one.
         foreach ($ids as $menuid)
         {
            if (!$table->delete((int) $menuid))
            {
               return false;
            }
         }
         // Rebuild the whole tree
         $table->rebuild();
      }
      return true;
   }

}

如果我没弄错的话,Joomla核心代码会自动实现这一点。我认为你想要的是不可能的。为什么要将其从管理组件列表中删除?该组件仅用作需要代理类的模块的组件帮助器。使用组件是我知道的实现这一点的唯一方法。如果我没有弄错的话,Joomla核心代码会自动实现这一点。我认为你想要的是不可能的。为什么要将其从管理组件列表中删除?该组件仅用作需要代理类的模块的组件帮助器。使用组件是我所知道的实现这一点的唯一方法。