New Hook Request - COMPILER_BEFORE_OUTPUT [message #164978] |
Mon, 11 April 2011 15:11 |
|
Dayo
Messages: 101 Registered: April 2011
Karma: 0
|
Senior Member |
|
|
A hook placed after the forum has been loaded but BEFORE anything, including headers, has been sent, will be useful ... to me at least.
Getting tighter integration will be possible in my plugin could keep full track of requests.
For example, take this flow of events as it stands now...
- User requests Page X
- Core code determines user is not logged in
- User is redirected to login page
- Plugin uses COMPILER_FINALIZE_PAGE hook just before display
- Plugin send user to CMS login and feeds CMS with return params which in this case has to be front page as it has no way of knowing user actually wanted Page X.
- User is redirected to FUDforum Front page after login
Compared to ....
- User requests Page X
- Core code determines user is not logged in
- Plugin uses COMPILER_BEFORE_OUTPUT hook before redirection headers are sent
- Plugin sets session var "previous_request" as equal to "current_request" (which may be empty in which case "previous_request" will default to FUDforum front page) and then stores request url in session as "current_request"
- User is redirected to login page
- Plugin uses COMPILER_BEFORE_OUTPUT hook again
- Plugin sets session var "previous_request" as equal to "current_request" (which will not be empty) and then stores request url in session as "current_request"
- Plugin uses COMPILER_FINALIZE_PAGE hook just before display
- Plugin sends user to CMS login and feeds CMS with return params which in this case will be session var "previous_request".
- User is redirected to FUDforum Page X after login
The important thing is that the hook should be fired before anything is sent at all and preferably after GLOBALS.php has been loaded.
[Updated on: Mon, 11 April 2011 15:17] Report message to a moderator
|
|
|
|
|
Re: New Hook Request - COMPILER_BEFORE_OUTPUT [message #164995 is a reply to message #164991] |
Wed, 13 April 2011 13:34 |
|
Dayo
Messages: 101 Registered: April 2011
Karma: 0
|
Senior Member |
|
|
OK. first the bad news. I finally completed the plugin, or so I thought, after slugging through. After activating and trying it however, a big, fat nothing happened.
It turns out that the documentation for the hook I was relying on, COMPILER_FINALIZE_PAGE, is, shall we say, a bit misleading.
It says, in an example of imprecise language, "Modify a page before it's written out" when it should say something like "Modify template html data before it is built as a template file".
Now. I am sure to the person that wrote it, being familiar with the application, the second meaning is obvious ... particularly since the hook has the term "COMPILER" in it but to me, I saw "Modify a page (web output page) before it is sent to the browser".
I found out the true meaning after several hours of head scratching and digging in the code.
<Side Show Begin>
Lord Raglan, at Battle of Balaclava during the Crimean war, sent an order to the 600 men of the Light Brigade to "advance rapidly to the front, follow the enemy, and try to prevent the enemy carrying away the guns". He had just watched the Heavy Brigade charge into Russians and drive them back in another area but the Russians had captured some Turkish artillery pieces and he didn't want them to retreat with those pieces.
The Light Brigade however was positioned in a valley with Russian Guns at the other end. To try to take these was suicide but being unable to read Raglan's mind, decided an order was an order and proceeded to charge the position. Half of the Light Brigade was wiped out simply because Raglan didn't say "... retreating with the guns they captured earlier from the Turks".
Imprecise language kills!
<Side Show End>
Now the good news.
All the code is ready. It just needs a hook that is called after all the output has been put together and just before the output is sent to the browser. Hopefully, this can be achieved.
Some advice on where to add such a hook will be appreciated.
Thanks a mil!
[Updated on: Wed, 13 April 2011 13:37] Report message to a moderator
|
|
|
|
|