Publishing Engine Programmer's Guide > PTC Arbortext Publishing > The Publishing Framework > The Publishing Framework Hook
  
The Publishing Framework Hook
The publishing framework hook allows user code to run at several points of publishing processing that uses compose_for_type() functions described in The Outer Layer of the Publishing Framework.
You can create an ACL compositionframeworkhook hook function and register it using the ACL add_hook function. The publishing framework will invoke the hook function before compose_for_type() starts executing, after each operation compose_for_type() runs, and before compose_for_type() returns to its caller. Your hook function can return 0 to allow compose_for_type() to continue executing or return a negative value to terminate the publishing operation. It can modify any or all values in the publishing parameter array, thereby controlling the future flow of execution in compose_for_type().
The publishing framework hook function has the following prototype:
hook(doc, type, where, params[])
doc is the document identifier of the document being published.
type is the name of the pipeline or type of published output as represented by its .ccf base file name.
The complete list of pipeline .ccf files is located in Arbortext-path\composer.
where is the point in publishing processing where the hook is called. It is a literal string value that is passed by the publishing framework to the hook function each time the framework calls it. For each string, there is a corresponding ACL variable that specifies the point of operation.
Arbortext-path\packages\tools\composer.acl contains the set of HK_variable-name ACL variables with defined values you can use for a where string specification. You can determine the point at which the hook function is called by finding the variable associated with one of the where values and searching for it in compose.acl.
params[] is the parameter array that holds the parameters and values to be used by the pipeline.
See the Arbortext Command Language Reference entry for compositionframeworkhook, which describes its syntax and use, including how to specify the arguments.
Before writing a publishing framework hook, be sure to examine compose.acl and experiment with the example ACL script that follows to understand how the compose_for_type() functions work.
* 
It’s possible the behavior of this hook can change from release to release. You should check your publishing framework hook code with each release of Arbortext software.
The following example ACL function prints the location from which it is called, and sets that function up as a publishing framework hook:
package testhook;
function compFrameHook( doc, type, where, params[] ) {
local is_e3 = ( main::is_e3 ? "e3" : "local" );
eval "chf: $is_e3 doc=$doc type=$type where=$where" output=*debug;
}
set debug==extwin;
add_hook( "compositionframeworkhook", "testhook::compFrameHook" );
eval "installed composition framework hook" output=*debug;
If you place this ACL script in a custom\init directory, it will echo its parameters to the Arbortext Diagnostics window as you publish a document. You might find it a useful starting point for implementing a hook function of your own, because it will illustrate the parameters your hook function should expect.