Topic Closed
fly06
263 Posts
20.6K Downloads
1 Themes
8 Plugins

I would like to register two different functions on the same hook in the Addon.ini file:

[Hook]
script = 'myScript_1.php'
class = 'myClass_1'
method = 'myMethod_1'
 
[Hook]
script = 'myScript_2.php'
class = 'myClass_2'
method = 'myMethod_2'
 
A first sight it does not work. 
 
Only the second one is registered.
 

 

10 years ago#4731

Dominion IT
126 Posts
42.1K Downloads
16 Themes
5 Plugins

Can you not have 1 for example 

myScript_Combined registered, that will call the other 2  scripts for you ? 

Then at least you can control which one gets called before the other.

Johannes

10 years ago#4732

fly06
263 Posts
20.6K Downloads
1 Themes
8 Plugins

Thanks for the workaround Johannes.

This should work but necessitates an extra file to be added to the plugin to dispatch the hook call to the proper file/class/method.

I was just wondering why the second hook overwrites the first one since I cannot see any reason why we couldn't register several functions on the same hook within a given plugin?

 

 

10 years ago#4734

Dominion IT
126 Posts
42.1K Downloads
16 Themes
5 Plugins

Think it is per design that each plugin can only have one entry per hook. If you look at config file for example the hooks array

'hooks' => 

 

  array (
    'GetHead' => 
    array (
      'ute2juq' => 
      array (
        'addon' => 'ute2juq',
        'script' => '/data/_addoncode/ute2juq/dominionslideshow_prep_header.php',
        'method' => 'dominionslideshow_prep_header',
      ),
    ),
 
and if you look at the installation process, it seems AddHook overrides the entry the whole time, thus the reason
that only the last one is accepted.
 
$config['hooks'][$hook][$this->install_folder_name] = $add;
 
thus currently by design, each plugin can only have one.
10 years ago#4735

fly06
263 Posts
20.6K Downloads
1 Themes
8 Plugins

Thanks for sorting this question out.

I have resolved the issue by implementing the workaround.

 

10 years ago#4742

Topic Closed

 

News

elFinder 2.1.50 in Upcoming Release
12/28/2019

A new release for Typesetter is in the works with a lot of improvements including the ... Read More

Typesetter 5.1
8/12/2017

Typesetter 5.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More

More News

creisi productions

Dienstleistungen von creisi productions, Ennetb├╝rgen (Schweiz): * Konzeption, Planung und Erstellung Ihres Internet-Auftritts * Betreuung und Aktualisierung/Pflege Ihrer Websi...

Find out more about our Provider Spotlight

Log In

  Register