Magento – Getting custom email template name in system configuration

adminconfigurationemail-templatesmagento-1.7template

I need to get custom email template in admin system configuration.

system.xml

This is my email template field code.

<email_template>
    <label>Email Template</label>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
    <sort_order>5</sort_order>
    <frontend_type>select</frontend_type>
    <source_model>adminhtml/system_config_source_email_template</source_model>
</email_template>

config.xml

<template>
    <email>
    <custom_email_template translate="label" module="eztestimonial">
    <label>Custom Email Template</label>
    <file>mymodule/custom_email.html</file>
    <type>html</type>
    </custom_email_template>
    </email>
</template>
<default>
    <mymodulesettings>
      <email>
          <email_template>custom_email_template</email_template>
      </email>
    </mymodulesettings>
</default>

And i have added email.html file in locale/en_US/template/email/mymodule/ path
Now i got a outut like this
enter image description here

But i need to show my custom email name in that dropdown.
like:enter image description here
I refer AW Blog Extension for this.

Best Answer

In your config.xml you should have your template declared inside the global tag and have a label on it.

<global>
...
    <template>
        <email>
            <custom_email_template translate="label" module="eztestimonial">
                <label>Custom Email Template</label><!-- this should be shown in the config dropdown-->
                <file>mymodule/custom_email.html</file>
                <type>html</type>
            </custom_email_template>
        </email>
    </template>
...
</global>

Right now you have this outside the global tag.

[EDIT]
And in order to work, the path of your system.xml field must match the name of the template with _ instead of /. In your case custom_email_template.

So your system.xml should look like this:

<sections>
    <custom ...>
       ....
       <groups>
           <email ....>
              ...
              <template>
                  <label>Email Template</label>
                  <show_in_default>1</show_in_default>
                  <show_in_website>1</show_in_website>
                  <show_in_store>1</show_in_store>
                  <sort_order>5</sort_order>
                  <frontend_type>select</frontend_type>
                  <source_model>adminhtml/system_config_source_email_template</source_model>
              </template>
           </email>
       </groups>
    </custom>
</sections>

And the <default> tag in config.xml should be

<default>
    <custom>
      <email>
          <template>custom_email_template</template>
      </email>
    </custom> 
</default>
Related Topic