SMF Development > Next SMF Discussion

[2.1] Hooks in 2.1

<< < (8/10) > >>

inter:
 8)

Who.php:

find:

--- Code: --- $context['copyrights'] = array(
'smf' => sprintf($forum_copyright, $forum_version),

/* Modification Authors:  You may add a copyright statement to this array for your mods.
Copyright statements should be in the form of a value only without a array key.  I.E.:
'Some Mod by Thantos &copy; 2010',
$txt['some_mod_copyright'],
*/
'mods' => array(
),
);
--- End code ---

replace:

--- Code: --- $context['copyrights'] = array(
'smf' => sprintf($forum_copyright, $forum_version),

/* Modification Authors:  You may add a copyright statement to this array for your mods.
Copyright statements should be in the form of a value only without a array key.  I.E.:
'Some Mod by Thantos &copy; 2010',
$txt['some_mod_copyright'],
*/
'mods' => array(
),
);
call_integration_hook('modification_authors', array(&$context['copyrights']['mods']));
--- End code ---

emanuele:

--- Quote from: 4Kstore on October 23, 2011, 03:03:40 AM ---For me the use of the hook will exist if there is good documentation on them, so that has to be good translations and good examples of their use.
--- End quote ---
That is a good point.
But there is a problem: write documentation takes time. I just did a search in the code for "call_integration_hook" and I found 248 matches, considering the function itself, a couple of places where SMF checks if the function exists, some hooks that are used in multiple places, I think we are about 220 unique hooks (*but* some of them are "generic" so that a single hook can cover multiple things (like lists and menus), so in the end the real number of things you can change with hooks in 2.1 is difficult to estimate).

At the moment hooks documentation is on the wiki, but this solution doesn't scale so well. It is okay for a bunch of hooks (15/30), but with the numbers we will have in 2.1 it will be very difficult to document each and every hook that way, so we are considering using comments in the code itself (that will probably be something will be cleaned up during the beta/rc phase and any help would be highly appreciated of course!)

Of course write examples is "easier". There are already few on the wiki (e.g. how to add a custom action) and anybody can (and is encouraged) to write new ones (don't worry if your English is not perfect, we have K@ that can translate anything it into gibberish! :P).

tl;dr: if you want to write some documentation feel free to edit the wiki and if in the process of writing you would have any doubt, feel free to post in the SMF Documentation Help board!

inter:
to do inquiries in a cycle it is impossible  :-\
I think that it is necessary to alter this code

Who.php

--- Code: --- $data = array();
foreach ($url_list as $k => $url)
{
...

// Maybe the action is integrated into another system?
if (count($integrate_actions = call_integration_hook('integrate_whos_online', array($actions))) > 0)
{
foreach ($integrate_actions as $integrate_action)
{
if (!empty($integrate_action))
{
$data[$k] = $integrate_action;
break;
}
}
}
}
--- End code ---

emanuele:

--- Quote from: Inter on September 04, 2012, 02:33:14 AM ---to do inquiries in a cycle it is impossible  :-\
I think that it is necessary to alter this code

--- End quote ---
Why it should be changed? And how?
Could you please provide an example?
If you think it's a bug, please open a topic in Bug Reports. ;)

inter:

--- Quote from: emanuele on September 04, 2012, 03:44:20 AM ---
--- Quote from: Inter on September 04, 2012, 02:33:14 AM ---to do inquiries in a cycle it is impossible  :-\
I think that it is necessary to alter this code

--- End quote ---
Why it should be changed? And how?
Could you please provide an example?
If you think it's a bug, please open a topic in Bug Reports. ;)

--- End quote ---

link

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version