Domanda

I'm recently started with making an own component in Joomla (3.x). And now i'm trying to automatically append subgroups to a new usergroup.

What i want is the following: --> When i create a new usergroup A, i want to automatically add subgroup B, subgroup C and subgroup D to usergroup A. (something like a OnAfterSave?)

In /libraries/joomla/table/usergroup.php i found a function that rebuild the lft & rgt values for me. Maybe i can do something with that? Or should i just build the query by myself?

And I don't know where to build the selfmade onAfterSave function, which makes the subgroups...

I hope anybody can help me with this problem? Thanks in advance!

È stato utile?

Soluzione

OnAfterXXXXSave() are Joomla events that are handled by area specific plugins.

You can either write a plugin to respond to standard Joomla events or you can add support for plugins to a component you've written.

As you can see from that list there is no event associated with com_categories however spelunking the /administrator/com_categories directory I can see that category.php triggers onContentBeforeSave() and onContentAfterSave() in the save() of CategoriesModelCategory (i.e. models/category.php).

class CategoriesModelCategory extends JModelAdmin
{
:
    public function save($data)
    {
        $dispatcher = JEventDispatcher::getInstance();
    :
    // Trigger the onContentBeforeSave event.
    $result = $dispatcher->trigger($this->event_before_save, array($this->option . '.' . $this->name, &$table, $isNew));
    :
    :
    // Trigger the onContentAfterSave event.
    $dispatcher->trigger($this->event_after_save, array($this->option . '.' . $this->name, &$table, $isNew));

Based on that, I would start with a content plugin (tutorial) and adapt it to your use case.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top