Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
Hi,
If your'e using a page as an email template, I would run the whole ouput through a filter which then rewrites all URLs to absolute. Or you can hook into the URL rewriter:
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))] public class DataInitialization : IInitializableModule { public void Initialize(InitializationEngine context) { Global.UrlRewriteProvider.ConvertingToExternal += this.RewritingToExternal; } public void Uninitialize(InitializationEngine context) { Global.UrlRewriteProvider.ConvertingToExternal -= this.RewritingToExternal; } public void Preload(string[] parameters) { } private void RewritingToExternal(object sender, UrlRewriteEventArgs e) { // Check if the current page is an email template var pageIsEmailTemplate = true; if (pageIsEmailTemplate) { e.Url.Host = "www.example.com"; e.IsModified = true; } } }
All links, image urls and so on will have absolute URLs with the host www.example.com.
Hi Johan,
We are using Content Areas in the email templates. Using MVC postal to send views based emails.
The model for the email view is generated on the fly from an existing page that contains content areas. When we drop contents (block, images) in the content area, by default it gives the path the image to be relative. Is there a way to change that to absolutel.
Thanks,
Syed
Yes, by having a filter that rewrites the whole output. It will take care of all URLs, not just the ones from your content area.
Your other option is to concatenate the realtive URL with a host, manually, for every item in your content area.
Can you use Tags for showing email-friendly templates?
Have a look at Alloy website and tags.
Sounds good. It would be greate if you could provide a sample code snippet or link that we can get an idea from. The issue I am facing is that the email page is not being generated by the controller but just by calling the "FindPagesWithCriteria" method. Can we still use the filter on the page object?
Thanks,
Syed
How to get the absolute URL of each item in content in the ContentRendere?
We want to send the images or links in the email. Which is a contentare on a page. When we send the email the image doesn't show up. Is there a way to get the absolute URL of each item in the content in the rendere method?
Thansk!