Sohowiki Sandbox

From Sohowiki
(Difference between revisions)
Jump to: navigation, search
(hook_attach)
(hook_attach)
Line 6: Line 6:
 
Includes (attaches) your custom script (plugin file) at a pre-designated place (hook id) in the Pro Edition source code.
 
Includes (attaches) your custom script (plugin file) at a pre-designated place (hook id) in the Pro Edition source code.
  
'''Example 1 - What a designated hook looks like in the Pro Edition source code'''
+
'''Example 1 - What a designated hook looks like in the Pro Edition source code'''<br>
 
''Taken from in sohoadmin/program/header.php (~line #375 as of v4.9 Beta2)''
 
''Taken from in sohoadmin/program/header.php (~line #375 as of v4.9 Beta2)''
 
<pre>eval(hook("header.php:top_javascript", basename(__FILE__)));</pre>
 
<pre>eval(hook("header.php:top_javascript", basename(__FILE__)));</pre>
  
'''Example 2 - calling hook attachement() from your install_manifest.php'''
+
'''Example 2 - calling hook attachement() from your install_manifest.php'''<br>
 
''Taken from QuickEdit Dropdown Menu plugin''
 
''Taken from QuickEdit Dropdown Menu plugin''
 
<pre>hook_attach("quickedit_js.php", "header.php:top_javascript");</pre>
 
<pre>hook_attach("quickedit_js.php", "header.php:top_javascript");</pre>
This effectively tells Pro Edition to include() your script at the designated (by hook id) location.
+
This effectively tells Pro Edition to include() your script at the designated (by hook id) location. So when Pro Edition processes header.php and gets to that line with a hook() on it that your plugin has attached to (by calling hook_attach in its install_manifest.php), it basically does this...
 
+
This is (conceptually) what happens when Pro Edition processes header.php and gets to that line with the hook() on it that you've attached to with hook_attach()...
+
 
<pre>include("[path_your_plugin_folder]/quickedit_js.php");</pre>
 
<pre>include("[path_your_plugin_folder]/quickedit_js.php");</pre>
  

Revision as of 15:57, 18 May 2006

Write now, organize and place later. This is the place to draft content before you know exactly where it should go...also good place for expermimenting with wiki markup.

hook_attach

hook_attach(plugin file, hook id)

Includes (attaches) your custom script (plugin file) at a pre-designated place (hook id) in the Pro Edition source code.

Example 1 - What a designated hook looks like in the Pro Edition source code
Taken from in sohoadmin/program/header.php (~line #375 as of v4.9 Beta2)

eval(hook("header.php:top_javascript", basename(__FILE__)));

Example 2 - calling hook attachement() from your install_manifest.php
Taken from QuickEdit Dropdown Menu plugin

hook_attach("quickedit_js.php", "header.php:top_javascript");

This effectively tells Pro Edition to include() your script at the designated (by hook id) location. So when Pro Edition processes header.php and gets to that line with a hook() on it that your plugin has attached to (by calling hook_attach in its install_manifest.php), it basically does this...

include("[path_your_plugin_folder]/quickedit_js.php");

hook_overwrite

hook_overwrite(source file name, plugin file name)

Example 1 - calling hook_overwrite from your install_manifest.php

hook_overwrite("sohoadmin/program/main_menu.php", "main_menu-helloworld.php");
Personal tools