I want to create a view to show all the created templates and provide the user option to edit and delete the already uploaded file..For example a view like Mailings>>Message Templates.

I have seen to implement this i want to create a tpl file and tpl.php file for it. I don't get how should i implement this in my extension.mean i don't get how to generate a tpl.php file and create route for it.

Hope you understand the question. Thanks in advance


Take a look at the documentation for civix. To create a page like the mailing templates you could use civix generate:form, as described at https://docs.civicrm.org/dev/en/latest/extensions/civix/#generate-form

If you prefer to create an angular page, you can also use civix to generate the basic code: https://docs.civicrm.org/dev/en/latest/framework/angular/quickstart/#create-an-angular-module

  • thank you for your response. can i how should i create a table within the buildquickform method ? – safron Aug 11 '20 at 18:20
  • 1
    You assign variables in hook_civicrm_buildForm() using $this->assign('variable_name', $value); and then you can display them in a table in the .tpl file, e.g. <div>something</div><div>{$variable_name}</div>. Take a look at an existing table like the mailing templates to see what it does. It's technically a page not a form, but they're similar. github.com/civicrm/civicrm-core/blob/0dcdc386/CRM/Admin/Page/… and github.com/civicrm/civicrm-core/blob/0dcdc386/templates/CRM/… – Demerit Aug 11 '20 at 18:31
  • Thank you very much for the detail answer – safron Aug 12 '20 at 3:02
  • i want to display the templates name as the row of a table. i planned to extract the data from a sql query and send it into the tpl file and print it by using a loop. however i don't get how should i send the sql result to front end?? in line 127 of 'github.com/civicrm/civicrm-core/blob/… ' they used a $template_row variable. I'm just wondering where did they assign these variable...could you please clarify my doubts ? Thanks in advance – safron Aug 12 '20 at 14:09
  • 1
    Look at civix generate:entity. It will help create the classes you can use. And see docs.civicrm.org/dev/en/latest/framework/database/… for the xml definitions. – Demerit Aug 12 '20 at 15:59

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.