Skip to content

Add template overrides

M. Dent requested to merge dentm42/core:add-template-overrides into dev
  • Fix root not prepended to file paths when using get_intltext_template(file,$root).
  • Add support to override specific templates or "rehome" the entire template directory via .htconfig.php
\App::$override_markup_templates["__root__"]["__template.tpl__"] ...
            ["content"] = "raw template content" // if exists, override file lookups
            ["file"] = "__new_filename__" // replaces $file in lookups
            ["root"] = "__new_rootdir__" // replaces $root in lookups


\App::$override_intltext_templates["__root__"]["__template.tpl__"] ...
            ["content"] = raw template content [if  this key exists it overrides file lookups]
            ["file"] = "__new_filename__" // replaces $file in lookups
            ["root"] = "__new_rootdir__" // replaces $root in lookups

If default templates are being overridden, ["__root__"] must be set to ["ROOT"] (eg:
    \App::$override_intltext_templates["ROOT"]["__template.tpl__"] ...

Using this mechanism, it is also possible to override templates in addons for localization and customization 
 as long as the template authors used either get_markup_template or get_intltext_template.

\App::$override_markup_templateroot = "__dirname__"  // Sets a directory that will be prepended this 
 to the "$root" of calls to get_markup_template($file,$root) and get_intltext_template($file,$root).

The lookups will use the structure [{$templateroot}/][{$root}/]view/[$lang|en|tpl]/{$file}
Edited by M. Dent

Merge request reports