0

I want to override predefined template file in my extension.How to do that using php?

  • Can you give more info. Is this a CiviCRM template or your CMS template? And which template are you wanting to override? – Iowa Boy Feb 22 at 16:11
  • I want to load my custom template override on dashboard template – deepak Feb 22 at 16:17
1

Hardcoding cusomised templates into extensions is in breach of extension development standards and can break on upgrades. Prevention of errors is an important priority to most developers to take pride in their craft and care about their clients.

The answer in your extension is to include the modified file in the path form template/CRM/path/to/template.tpl.php - but please find a better way. Civi users deserve great products that they get from other services, not this.

  • I appreciate their work. But I want to customize dashboard means I want to show all the contacts. – deepak Feb 24 at 19:06
  • Then don't just hijack a random field (like is_auto) if they need a custom field like you tried to last time. "I don't think it's used for anything you need it for". – JohnFF Feb 24 at 19:43
  • Will you provide some code snippets to overwrite template? – deepak Feb 25 at 7:02
  • 1
    Don't hijack fields Deepak! Do things properly and give your clients a quality service. – JohnFF Feb 26 at 14:58
0

You can use hook_civicrm_alterTemplateFile to select a different template file - but beware of the problems of overriding templates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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