diff --git a/eWAYRecurring.civix.php b/eWAYRecurring.civix.php
index 360ea12..c512dff 100644
--- a/eWAYRecurring.civix.php
+++ b/eWAYRecurring.civix.php
@@ -99,11 +99,6 @@ function _eWAYRecurring_civix_civicrm_config($config = NULL) {
$configured = TRUE;
$extRoot = __DIR__ . DIRECTORY_SEPARATOR;
- $extDir = $extRoot . 'templates';
- if (file_exists($extDir)) {
- CRM_Core_Smarty::singleton()->addTemplateDir($extDir);
- }
-
$include_path = $extRoot . PATH_SEPARATOR . get_include_path();
set_include_path($include_path);
_eWAYRecurring_civix_mixin_polyfill();
diff --git a/info.xml b/info.xml
index 7d8c9b0..7c942d9 100644
--- a/info.xml
+++ b/info.xml
@@ -23,11 +23,12 @@
CRM/eWAYRecurring
- 22.12.1
+ 23.01.0
menu-xml@1.0.0
setting-php@1.0.0
+ smarty-v2@1.0.0
diff --git a/mixin/smarty-v2@1.0.0.mixin.php b/mixin/smarty-v2@1.0.0.mixin.php
new file mode 100644
index 0000000..0b37105
--- /dev/null
+++ b/mixin/smarty-v2@1.0.0.mixin.php
@@ -0,0 +1,56 @@
+getPath('templates');
+ if (!file_exists($dir)) {
+ return;
+ }
+
+ $register = function() use ($dir) {
+ // This implementation is useful for older versions of CiviCRM. It can be replaced/updated going forward (v1.1+).
+ $smarty = CRM_Core_Smarty::singleton();
+ if (!is_array($smarty->template_dir)) {
+ $this->template_dir = [$smarty->template_dir];
+ }
+ if (!in_array($dir, $smarty->template_dir)) {
+ array_unshift($smarty->template_dir, $dir);
+ }
+ };
+
+ // Let's figure out what environment we're in -- so that we know the best way to call $register().
+
+ if (!empty($GLOBALS['_CIVIX_MIXIN_POLYFILL'])) {
+ // Polyfill Loader (v<=5.45): We're already in the middle of firing `hook_config`.
+ if ($mixInfo->isActive()) {
+ $register();
+ }
+ return;
+ }
+
+ if (CRM_Extension_System::singleton()->getManager()->extensionIsBeingInstalledOrEnabled($mixInfo->longName)) {
+ // New Install, Standard Loader: The extension has just been enabled, and we're now setting it up.
+ // System has already booted. New templates may be needed for upcoming installation steps.
+ $register();
+ return;
+ }
+
+ // Typical Pageview, Standard Loader: Defer the actual registration for a moment -- to ensure that Smarty is online.
+ \Civi::dispatcher()->addListener('hook_civicrm_config', function() use ($mixInfo, $register) {
+ if ($mixInfo->isActive()) {
+ $register();
+ }
+ });
+
+};