FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » Fudla! Plugin Core Code Changes (Requirements for FUD 3.0.2 <-> Joomla integration)
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Fudla! Plugin Core Code Changes [message #165036 is a reply to message #165035] Mon, 18 April 2011 15:36 Go to previous messageGo to previous message
Dayo is currently offline  Dayo   Bahrain
Messages: 101
Registered: April 2011
Karma:
Senior Member
This should do the job and decouples PRE_TEMPLATE from the output processing.
It is now there simply if the user wants to run code before the template is put together and before redirection headers are sent.
I.E. it does not need to be initialised to capture and process output html which is now all done by the POST_TEMPLATE hook.

			/* Call themed template. */
			if (defined('plugins')) {
				plugin_call_hook('PRE_TEMPLATE');
				if (isset($plugin_hooks['POST_TEMPLATE'])) {
					ob_start();
				}
			}
			require($WWW_ROOT_DISK . fud_theme .'language.inc');    // Initialize theme's language helper functions.
			require($WWW_ROOT_DISK . fud_theme . $t .'.php');
			if (defined('plugins') && isset($plugin_hooks['POST_TEMPLATE'])) {
					echo plugin_call_hook('POST_TEMPLATE', ob_get_contents());
					ob_end_clean();
				}
			}



The sample plugin (file: x.plugin) to capture and process output becomes:
<?php
plugin_add_hook('POST_TEMPLATE', 'plugin_x_process_output');

function plugin_x_process_output($data) {
	//$modified_data = Modify $data, add headers, footers, go mad...
	return $modified_data;
}
?>



PRE_TEMPLATE could be used in another sample plugin (file: y.plugin):
<?php
plugin_add_hook('PRE_TEMPLATE', 'plugin_y_background_work');

function plugin_y_background_work() {
	//Do whatever....
}
?>


Not tested though.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Tips for higher iPhone/Andriod/Pre compatibility
Next Topic: Help Needed - fud_user_reg class
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 21 23:36:40 GMT 2024

Total time taken to generate the page: 0.04002 seconds