Jump to content

Adding custom page classes for module-specific templates


Recommended Posts

Just a brief 'sort of' tutorial based on my experiences documented here.

I have built a couple of modules in the past which created and used their own specific templates and which had page classes associated with these. My approach has been to put the scripts containing the page classes in the same directory as the module (rather than the classes directory) so as to keep all the module-related stuff together. I would then'include/require' those scripts in my module init() method. This worked very well until recently. Then, as documented in the above link, I found that in some circumstances (the details of which still escape me but might be to do with the number of templates involved) the page classes were not always being applied in time for all templates.

My solution is to put the include/require in the module's __construct() method as it is called before init(). This seems to work, but bear in mind that the full API is not available at this time.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...