Executing code on all page types

Permalink
Hi all,

I want to execute some code on all page types in my site. I know how to set up a Page Type controller and add code to the on_start method of that particular controller, but what to do if you have, say, five or more Page Types?

I can't imagine copying the same code into every on_start method of five different Page Type controllers, there must be an easier way ;-)

Help and/or tips would be much appreciated.

Greetz, Jan

jankoehoorn
 
xaritas replied on at Permalink Reply
Easy, but brittle: create a superclass the five PageTypes so that they can share the same on_start. Slightly more work but less likely to screw you over with mysterious bugs at some point in the future: encapsulate the on_start behavior in a library object, and simply invoke the library code from each PageType's on_start hook.