I am making custom library to extend the functionality of the Joomla framework core, and I am placing all my classes in a custom library folder like so:
- libraries
- joomla
- my_custom_library
I wish for all of my classes to be present before any module rendering is performed, so that I can use them for my custom module code. Right now, the only place I can think of to load my classes in is in my template file:
<?php
// index.php in template folder
require_once(JPATH_LIBRARIES . DS . 'my_custom_library' . DS . 'Page.php';
require_once(JPATH_LIBRARIES . DS . 'my_custom_library' . DS . 'User.php';
// and so on...
// and then the HTML document follows with <jdoc:include type="modules" /> syntax
Unfortunately, it seems that Joomla parses my template document, reads all of my jdoc:include
s, and stores all of my modules' output before executing these require_once
calls for my custom library, because when I create a new module and check to see whether my class exists, it always returns false.
<?php
// mod_something_custom.php in something_custom module folder
echo (bool) class_exists('MyCustomPageClass'); // false
How can I load in all of my custom classes before anything gets rendered (in particular, my modules)? I don't wish to alter the core if possible.
UPDATE: I just found out that modules included through <jdoc:include type="modules />
do in fact see that my classes exist. However, this is not the case for <jdoc:include type="component" />
. In this case, I have com_content articles using a {loadposition}
declaration to load the module and render it. When I do this, then my classes cease to exist!