我创建了一个模块,我想添加一些自定义电子邮件模板作为电子邮件模板下拉列表的选项,例如Admin > System > Configuration > Customers > Customer Configuration
中的"创建新帐户"。
我尝试在我的自定义模块中添加一个节点,例如
<global>
<template>
<email>
<customer_account_create_template>
...
</customer_account_create_template>
</email>
</template>
</global>
请注意,当我写这篇文章时我没有我的代码,所以customer_account_create_template
可能不正确,但我成功地用我的自定义模板替换了该选项。
关键是,我想将其添加为另一个选项,而不是替换默认选项。那么,你有什么想法吗?
添加 config.xml
您应该在全局标签中声明模板并在其上贴上标签。
<global>
<template>
<email>
<custom_email_template translate="label" module="yourcustommodule">
<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>
系统.xml字段必须与模板的名称与 _ instead of /
匹配。在你的情况下custom_email_template。
因此,您的system.xml
应如下所示:
<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>
config.xml
中的<default>
标签应该是
<default>
<custom>
<email>
<template1>custom_email_template1</template1>
<template2>custom_email_template2</template2>
</email>
</custom>
</default>