I was writing an extension which injects a template snippet, and was working fine. While working on the PHP, without any change to the snippet, it's no longer loading (the rest of the extension IS working). The template is at <extensionname>/templates/Contact/Form/Contact.extra.tpl (NOT in a "custom templates" folder - though if I move it there, it works). I realize I have absolutely no idea how to check which file locations CiviCRM is checking for its template files, is there a way to see?

3 Answers 3


This code might help shed some light:

  $template = CRM_Core_Smarty::singleton();
  • Thank you! This did the exact trick. I'd accidentally screwed with the civix-generated hook_civicrm_config, so it wasn't adding my templates folder. Commented Mar 27, 2015 at 15:42

I think the real answer to this situation is: "don't use tpl.extra files in an extension". The reason is that there can be only one of them, and potentially many extensions. That little trick is really only suitable for in-house customizations, in which case you can stick it in the custom templates folder.

Here's some solutions to the same problem that do scale:

  • hook_civicrm_pageRun seems to only work on Pages, not Forms, per the docs? I unfortunately need to add Smarty markup. I'd tried loading the template into a region, but since there's Smarty, I could only use add("template"), and that needs a filepath. The docs don't explain how to construct the filepath, but the examples suggest the template has to be in the custom templates folder. Am I missing something obvious? Commented Mar 27, 2015 at 14:47
  • Probably now that you've solved your hook_civicrm_config problem adding a template to a region will work.
    – Coleman
    Commented Mar 27, 2015 at 15:57

When I'm working with custom code in CiviCRM particularly with extensions, I'll turn on System Settings -> Debugging.

You can find it at the following URL: /civicrm/admin/setting/debug?reset=1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.