Chaim
Chaim

Reputation: 2149

Joomla: Plugins that modify Categories

I am trying to make a plugin for Joomla that mimics all the changes you do on content categories in a menu item. So adding, deleting and editing the name of a category in a specific article will also make the same changes on a menu item.

A content plugin has events such as onBeforeContentSave and onAfterDisplayContent that allow you to process that data. How do I do the same thing for categories?

Upvotes: 0

Views: 163

Answers (1)

jlleblanc
jlleblanc

Reputation: 3510

Unfortunately, there isn't an onCategorySave event. The best approach I can think of would be to create a system plugin and check the task and option request variables for values of save and com_categories. Your plugin would look something like this:

<?php

defined('_JEXEC') or die('Restricted access');

jimport('joomla.plugin.plugin');


class plgSystemCategorysave extends JPlugin
{
    function onAfterInitialise()
    {
        if (!JFactory::getApplication()->isAdmin()) {
                return; // Dont run in frontend
        }

        $option = JRequest::getCmd('option', '');
        $task = JRequest::getCmd('task', '');

        if ($option == 'com_categories' && $task == 'save') {
            // your processing code here
        }
    }
}

Upvotes: 1

Related Questions