2

During plugin installation, is it possible to set it to be always the last one in its group? Thanks

  • Is this for a custom plugin you are writing? – Michael Yaeger Aug 16 '16 at 1:55
1

Yes. You need to have a installer script. Then in the install script do something like:

public function postflight($route, $_this)
{
    // Get a database connector object
    $db = JFactory::getDbo();

    try {
        // Enable plugin by default
        $q = $db->getQuery(true);

        $q->update('#__extensions');
        $q->set($this->db->quoteName('ordering') . ' = -1')
            ->where($this->db->quoteName('type') . ' = ' . $this->db->quote('plugin'))
            ->where($this->db->quoteName('element') . ' = ' . $this->db->quote('PLUGIN_NAME'))
            ->where($this->db->quoteName('folder') . ' = ' . $this->db->quote('system'));

        $db->setQuery($q);

        method_exists($db, 'execute') ? $db->execute() : $db->query();
    } catch (Exception $e) {
        throw $e;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.