![]() |
||
![]() ![]() Hooks
|
![]() |
![]() HooksAside from text File Readers, you've also got three tables of hook scripts called for each file in the Content folder. They're stored at user.publisher.hooks. There are also two hooks for Content Server's CGI. These are also stored in the user.publisher.hooks table. Choose Edit Hooks from the Publisher menu to edit the tables. At every turn, your scripts can look at publisher.data.file to get information about the current file, much the way your user.html.macros scripts might look at html.data.page. PreLoadScriptsThe first is 'preLoadScript' which is called before anything is done, before we even look at the file type. If this hook returns false, Content Server moves the file to the Processed Files folder and moves on to the next file.If any script in the table returns false, then the hook is considered to return false. All the scripts in the table are called anyway. PreBuildScriptsThen, if it's a text file, after it's loaded into the website table but before it's rendered, the 'preBuildScript' hook is called. As above, if this hook returns false, Content Server moves the file to the Processed Files folder and moves on to the next file.If any script in the table returns false, then the hook is considered to return false. All the scripts in the table are called anyway. NotifyScriptsAfter a page is rendered, a third hook, the 'notifyScript' hook, is called. The returned value is ignored by Content Server.CGIFiltersAll scripts placed in this table allow you to filter the html text of the CGI submit page before it's presented to the browser.These scripts take two parameters, the address of the CGI parameters table and the address of the html text. Any return value is ignored. You can also edit the CGI submit page text: it's stored at user.publisher.cgiText.submitPage. This text is yours to edit. CGINewPageFiltersScripts in this table allow you to modify the submitted page before it's written to disk, before Content Server later processes it.Scripts in this table take three paramaters: the path to where the file will be written, the address of the CGI parameters table, and the address of the pagetext. Any return value is ignored. Immediately after these scripts are called, the file is written to disk. What you can doThese hooks allow you to infinitely customize Content Server's behavior.The preLoadScript could be used to implement an alternate security system, or it could move files from one place in the Content folder to another. The PreBuildScript can be used to filter or alter the contents of the page in the website table before it's built -- or you could tell the page not to get built at all, or to build it in a different place. The notifyScript could be used, for instance, to re-build site outline and navigation pages. Or it could be used to add the text of the page to a database. One of the obvious uses for these hooks, in combination with the "Open Folders" list, is to archive mailing lists in a database. The pages wouldn't have to be rendered to disk at all, but placed straight in a Filemaker, Verona, or other database. Next: Browser Tips This page was built on a Macintosh running Frontier. Last modified 4/15/97; 1:07:47 PM. Copyright 1997 Userland Software. |