【问题标题】:Create custom plugin joomla with custom ordering on install在安装时使用自定义排序创建自定义插件 joomla
【发布时间】:2016-11-09 07:26:41
【问题描述】:

设置我的自定义插件以在 joomla 中加载最终插件是否有技巧?

我想在安装时而不是之后设置顺序。

是否有像 order="xxx" 这样的自定义参数在 xml 中设置?

【问题讨论】:

    标签: joomla


    【解决方案1】:

    我刚刚通过添加xml文件找到了答案

    <scriptfile>script.php</scriptfile>
    

    在脚本文件中

    <?php
    // No direct access to this file
    defined('_JEXEC') or die('Restricted access');
    
    /**
     * Script file of yourplugin component.
     */
    class plgSystemyourplginInstallerScript
    {
        /**
         * method to run after an install/update/uninstall method.
         */
        public function postflight($type, $parent)
        {
            $db = JFactory::getDbo();
            $query = $db->getQuery(true);
    
            $fields = array(
                $db->quoteName('ordering').' = '.(int) 999,
            );
    
            $conditions = array(
                $db->quoteName('element').' = '.$db->quote('wraprotect'),
                $db->quoteName('type').' = '.$db->quote('plugin'),
            );
    
            $query->update($db->quoteName('#__extensions'))->set($fields)->where($conditions);
    
            $db->setQuery($query);
            $db->execute();
            // $parent is the class calling this method
            // $type is the type of change (install, update or discover_install)
        }
    }
    

    不要忘记编辑您的插件名称 在 joomla 1.5 中编辑 #__extensions#__plugins 并删除$db-&gt;quoteName('type').' = '.$db-&gt;quote('plugin')这一行

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-08
      • 1970-01-01
      相关资源
      最近更新 更多