I'll take the Support Toolkit as example here, the toolkit doesn't rely on the phpBB
page_footer()functions but uses its own replacement methods to handle the tasks usually performed by these functions. The problem starts when you want to use a login system and call
login_box()(there are some other locations within the phpBB core with this behavior) this function calls
page_headerpreventing the third party application from using the correct "header" function. This behavior can cause unexpected behavior for the third party application as certain logic that will be present in its own header/footer functions won't be executed and on the other side the third party app might or might not initialise all information the phpBB function simply expect to have available causing other problems.
An other solution would be to copy all code from
login_boxand call a custom version which only calls the applications header/footer but this causes a lot of un-needed code duplication.
Determining whether the phpBB function has to be ignored will be done by passing a variable (
$page_footer_override) into the hook which is defaulted to
false. If the event is designed to override the phpBB function it will set this variable to
trueat which point phpBB will ignore the rest of the function (the same basic idea is applied with the "old" hook system, for example in
The parameters that will be passed into the hook will be those that are used to call the regular functions and the skip variable. For the page_header override hook this are:
- Code: Select all
$vars = array('page_title', 'display_online_list', 'item_id', 'item', 'page_header_override');
and for the page_footer hook:
- Code: Select all
$vars = array('run_cron', 'page_footer_override');
Some related discussion on IRC:
- Code: Select all
[2012-03-29 06:31:05] <nn-> erik| please specify where in the code you want to have the event
[2012-03-29 06:31:11] <nn-> and what its parameters should be
[2012-03-29 06:31:24] <nn-> all of our parameters are in/out
[2012-03-29 06:31:38] <nn-> to return a flag from listener you have to pass a boolean in as a parameter
[2012-03-29 06:31:41] <nn-> something like $show_header
[2012-03-29 06:31:52] <nn-> then you can change it in the listener
[2012-03-29 06:32:09] <nn-> accordingsy you need to also specify what code will become conditional on that flag
[2012-03-29 06:32:28] <nn-> and what the behavior would be if that code does not run, in the event the flag is changed to false
[2012-03-29 06:33:02] <erik|iOS_> Okay.
[2012-03-29 06:33:30] <erik|iOS_> I'll investigate a bit more on the workings of the event handler
[2012-03-29 06:46:46] |<-- rahulr92 has left freenode (Ping timeout: 252 seconds)
[2012-03-29 06:51:29] <erik|iOS_> nn-: would it be acceptable it the event sets an "skip" argument in the return data and than add an `if (skip) return;` the line after the dispatcher call?
[2012-03-29 06:51:51] |<-- JanSch_ has left freenode (Ping timeout: 260 seconds)
[2012-03-29 06:54:07] <unknownbliss> nn-: Why is the old hooks system still there? It should probably either be removed or added to extensions.
[2012-03-29 06:54:12] <unknownbliss> CC: igorw
[2012-03-29 06:54:51] <nn-> unknownbliss: let's not get carried away
[2012-03-29 06:55:08] <nn-> and one thing at a time
[2012-03-29 06:55:22] <unknownbliss> fair point
[2012-03-29 06:55:42] <unknownbliss> But doing the latter [b]should[/b] just be a few lines of code
[2012-03-29 06:55:49] <nn-> erik| yes probably
[2012-03-29 06:55:57] <nn-> except there is no "return data"
[2012-03-29 06:56:01] <nn-> all parameters are in and out
[2012-03-29 06:56:15] <nn-> unknownbliss: feel free to take a stab at it
[2012-03-29 06:56:19] <nickvergessen> <@erik|iOS_> nn-: would it be acceptable it the event sets an "skip" argument in the return data and than add an `if (skip) return;` the line after the dispatcher call?
[2012-03-29 06:56:26] <nickvergessen> was my first and best idea aswell so far
[2012-03-29 06:57:07] <erik|iOS_> I understand that but if you add an "skip = false" in you could change that to true in the event. Right?
[2012-03-29 06:57:17] <nn-> yes
[2012-03-29 06:57:46] <nickvergessen> we can also add that parameter in the other function?
[2012-03-29 06:57:54] <nickvergessen> so we dont have to edit all places=
[2012-03-29 06:58:22] <erik|iOS_> Okay. I need to get a lot more familliar with the event system :?
[2012-03-29 06:58:36] <unknownbliss> nn-: After I've finished more important stuff
[2012-03-29 06:58:55] <unknownbliss> erik|iOS_: Most of the events stuff you need to know about is symfony
[2012-03-29 06:59:02] <nn-> http://wiki.phpbb.com/Category:Events_and_Listeners
[2012-03-29 06:59:25] <unknownbliss> erik|iOS_: Just a note though, we use a event dispatcher wrapper
[2012-03-29 07:00:04] <unknownbliss> erik|iOS_: Look through https://github.com/phpbb/phpbb3/pull/529
[2012-03-29 07:00:14] <nn-> unknownbliss: https://github.com/phpbb/phpbb3/pull/571 ;)
[2012-03-29 07:00:40] <unknownbliss> hm... Thats got all the events in so the diff is rather large and more difficult to digest
[2012-03-29 07:00:53] <erik|iOS_> Okay. Thanks :)
[2012-03-29 07:01:36] <unknownbliss> oh I just opened the link, I assumed it was the hooks v2 PR.
[2012-03-29 07:02:13] <unknownbliss> I'll have a look at that later on
[2012-03-29 07:02:32] <nn-> erik| but generally speaking your proposal seems sensible
[2012-03-29 07:02:56] |<-- Raimon|iPad has left freenode (Quit: Colloquy for iPhone - http://colloquy.mobi)
[2012-03-29 07:02:57] <nn-> certainly we can take action based on what a listener returns