cancel
Showing results for 
Search instead for 
Did you mean: 

Server name and port in email template

dgenard
Champ on-the-rise
Champ on-the-rise
In urls appearing in an FTL email template, how to avoid hardcoding the server name and port in the template ?

Default email templates contain hardcoded server name and port, such as http://yourserver:8080/
But we would like to replace this by the server name/port which effectively sent the mail (development, staging, or production server).

Any idea ?

Denis
7 REPLIES 7

kevinr
Star Contributor
Star Contributor
Currently there is not a nice solution for this in 2.0. But we have implemented a "url" object for our FreeMarker template API in Alfresco 2.1, so you will do something like this:

${url.context}/something/moreurl

and the correct serverSmiley Tongueort will be used.

Thanks,

Kevin

pcuvecle
Champ in-the-making
Champ in-the-making
Hi,

${url.context} returns "alfresco" but no serverSmiley Tongueort  (v2.1.1)

sacco
Champ in-the-making
Champ in-the-making
On a similar subject, this also needs to be altered in the RSS feed template.

I was just looking at this: is the file RSS_2.0_recent_docs.ftl cached
somewhere, because i have just altered the file but Alfresco does not seem
to have responded to the changes, even through a restart?

kevinr
Star Contributor
Star Contributor
Hi,

${url.context} returns "alfresco" but no serverSmiley Tongueort  (v2.1.1)

You are quite right - my mistake the external server name/port is only available in the WebScript API through the absurl() template method:

href="${absurl("/myrelativeurl")}"

For plain non-webscript templates, it will have to be hardcoded in the template for now.

Kevin

kevinr
Star Contributor
Star Contributor
On a similar subject, this also needs to be altered in the RSS feed template.

I was just looking at this: is the file RSS_2.0_recent_docs.ftl cached
somewhere, because i have just altered the file but Alfresco does not seem
to have responded to the changes, even through a restart?

Are you sure you changed the right file i.e. the repo object stored in /Company Home/Data Dictionary/RSS Templates

Kevin

sacco
Champ in-the-making
Champ in-the-making
Oops, no!  I was trying to do something else at the some time
and was editing the copy in the exploded .war.   Smiley Surprisedops:

Thanks!

mindthegab
Champ in-the-making
Champ in-the-making
As Sourcesense at a client,
we implemented a request root object (for FTL as for JS) which wraps the current FacesContext HttpServletRequest object, and exposes it to both Freemarker and Javascript to make url, context path, etc. environment independent.
It's not thoroughly tested, by it worked ATM for both in web client FTLs (presentation templates + JSF embedded FTLs) and in the mail template, which is pretty much what we needed.


Hope this helps,
Gab