Foren

SetUp custom mail template in liferay control panel

thumbnail
devaraj s, geändert vor 10 Jahren.

SetUp custom mail template in liferay control panel

Regular Member Beiträge: 228 Beitrittsdatum: 21.05.12 Neueste Beiträge
Hi,
I have a requirement that , I need to set up custom velocity mail template(just like email notification template already we have) and I want to use my custom velocity variables in that template. Please anyone can one give me brief guideline how I can get it done?


Thanks in advance
thumbnail
Manish Yadav, geändert vor 10 Jahren.

RE: SetUp custom mail template in liferay control panel

Expert Beiträge: 493 Beitrittsdatum: 26.05.12 Neueste Beiträge
Hi Devraj,

Check below post might be they can help you

http://www.opensourceforlife.com/2012/06/custom-velocity-variable-in-liferay-61.html
https://www.liferay.com/community/wiki/-/wiki/Main/Email+Velocity+Template
http://thinkinginsoftware.blogspot.in/2010/03/velocity-templates-for-email.html



Thanks & Regards
Manish Banwari Lal Yadav
thumbnail
devaraj s, geändert vor 10 Jahren.

RE: SetUp custom mail template in liferay control panel

Regular Member Beiträge: 228 Beitrittsdatum: 21.05.12 Neueste Beiträge
Thanks for response manish,
Those links helps to create our custom velocity variables, But here I want to embed template in control panel and i want to integrate my custom variables with that template. So here It will help admin to manage the mail content easily. Please find the attached image,
thumbnail
devaraj s, geändert vor 10 Jahren.

RE: SetUp custom mail template in liferay control panel

Regular Member Beiträge: 228 Beitrittsdatum: 21.05.12 Neueste Beiträge
can anybody help me in this particular requirement emoticon
thumbnail
devaraj s, geändert vor 10 Jahren.

RE: SetUp custom mail template in liferay control panel

Regular Member Beiträge: 228 Beitrittsdatum: 21.05.12 Neueste Beiträge
I have created a ext plugin for my custom email template and stored in a path
ext-impl\src\com\mytemplate

and in portal-ext.properties added a entry like,
ext.myfirst.template=ext-impl\src\com\mytemplate\my_first_tmpl.tmpl

when i try to read this template in my custom portlet by using ,I am getting exception
Unable to open resource in class loader ext-impl/src/com/mytemplate/my_first_tmpl.tmpl


here is my code,
String firstTemeplate = PrefsPropsUtil.getContent("ext.myfirst.template")


facing exception,
ERROR [http-bio-8080-exec-46][ContentUtil:64] java.io.IOException: Unable to open resource in class loader ext-impl/src/com/mytemplate/my_first_tmpl.tmpl
java.io.IOException: Unable to open resource in class loader ext-impl/src/com/mytemplate/my_first_tmpl.tmpl
	at com.liferay.portal.kernel.util.StringUtil.read(StringUtil.java:1229)
	at com.liferay.util.ContentUtil._get(ContentUtil.java:59)
	at com.liferay.util.ContentUtil._get(ContentUtil.java:72)
	at com.liferay.util.ContentUtil.get(ContentUtil.java:43)
	at com.test.Testu1.doView(Testu1.java:25)
	at com.liferay.portal.kernel.portlet.LiferayPortlet.doDispatch(LiferayPortlet.java:218)
	at com.liferay.util.bridges.mvc.MVCPortlet.doDispatch(MVCPortlet.java:319)
	at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
	at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)


please anyone help me why this exception is throwing? and I observed in one of the thread like we cant read the template in our custom portlet. So can one guide me where i am doing mistake in this particular exception.
thanks in adavnce
thumbnail
devaraj s, geändert vor 10 Jahren.

RE: SetUp custom mail template in liferay control panel

Regular Member Beiträge: 228 Beitrittsdatum: 21.05.12 Neueste Beiträge
I have resolved the above issue, Now i really want help from someone to continue the further code implementation,
here I am producing my following approach,
1) Created ext plugin for custom template.
2) Created hook for custom velocity variables.
3) through session , i am reading velocity variables in ext plugin for template.
4) created a entry in database for templates and accessing this template in my another custom portlet.
5) I have embedded this custom portlet in control panel. and accessing created template in ext plugin from database entry.
6) next what i want here is, this template in control panel should be editable and applied changes in template should be apply to source template in ext plugin.

please anyone suggest me Is i am following proper approach? If I am right please help me out ,how i Can control in coding to make template editable in control panel?

Thanks in advance
thumbnail
devaraj s, geändert vor 10 Jahren.

RE: SetUp custom mail template in liferay control panel

Regular Member Beiträge: 228 Beitrittsdatum: 21.05.12 Neueste Beiträge
I get strucked in this particular implementation. If someone push me in the implementation will be grateful.

How about if I use configuration mode concept here? If I use this concept, Is it possible to reach my requirement.? Or someone have other idea on this please post your reply.

Thanks in advance
thumbnail
Mario Duck, geändert vor 10 Jahren.

RE: SetUp custom mail template in liferay control panel

New Member Beiträge: 7 Beitrittsdatum: 11.12.12 Neueste Beiträge
Hey Devaraj

Were you able solve this situation? I'm currently trying to implement a similar solution and came across your post. Any guidance would be appreciated emoticon
thumbnail
devaraj s, geändert vor 10 Jahren.

RE: SetUp custom mail template in liferay control panel

Regular Member Beiträge: 228 Beitrittsdatum: 21.05.12 Neueste Beiträge
Mario Duck:
Hey Devaraj

Were you able solve this situation? I'm currently trying to implement a similar solution and came across your post. Any guidance would be appreciated emoticon


Hi mario duck,
I am able to solve this requirement by following the below mentioned workflow,

1) place a mail template in directory structure
2) set mail template path in liferay property file.
3) access the mail template path through property file in a business code.
4) put variable values to template file from controller class and send a mail.

If you need any code help according to this workflow please mail me at devarajs16@gmail.com


Regards
Devaraj S
Nicola Baiocco, geändert vor 10 Jahren.

RE: SetUp custom mail template in liferay control panel

New Member Beiträge: 5 Beitrittsdatum: 27.11.13 Neueste Beiträge
Hi,

I solve this problem, for my requirements in Liferay 6.0.6, in this way:

1) I made jsp hook of:
- ROOT/html/portlet/enterprise_admin/settings/email_notifications.jsp;
- ROOT/html/portlet/enterprise_admin/settings/definition_of_terms.jspf;
In detail, for email_notifications.jsp, I added one or more sections into lifeary-ui:tabs and saved its input values (subject and body) like the others(all notifications are saved as portletpreferences of portal).

2)I made my NotificationUtil.java that retrieves portletpreferences (example: String body = PrefsPropsUtil.getString(companyId, "MyPrefsPropsName")) and sends the message through MailServiceUtil.

I hope this helps.