The structure of my umbraco website ( 4.5.2 ) is two root elements - Content and Website Data.
Website Data contains many things including items that represent the emails that the site sends out. The Email document type has properties for the from address, cc address etc
Originally the email content was entered into a Rich Text Editor with some Tags that I use to insert name etc. I have some .Net code that gets the Node content property, creates and sends an email.
The designer has been busy and I now have a really nice styled email but the markup is way too complicated to put into the Rich Text Editor, so I created a Template for this email, and set the email node to use that template.
I then used the umbraco.Library.RenderTemplate method to create the email body. This worked really well and sends out the email exactly as expected.
Unfortuanately after implementing this some strange errors started occurring. I think these error are occurring because after calling RenderTemplate, UmbracoContext.Current returns the Email node rather than the actual page that was being rendered before sending the email. RenderTemplate seems to change the CurrentPage.
Am I misusing RenderTemplate? Is there another way to render a node programmatically?
Ideally, the email would not be sent from the page render but put on a queue and processed by another process. There is no plans or time for this at the moment.
RenderTemplate changes CurrentPage
The structure of my umbraco website ( 4.5.2 ) is two root elements - Content and Website Data.
Website Data contains many things including items that represent the emails that the site sends out. The Email document type has properties for the from address, cc address etc
Originally the email content was entered into a Rich Text Editor with some Tags that I use to insert name etc. I have some .Net code that gets the Node content property, creates and sends an email.
The designer has been busy and I now have a really nice styled email but the markup is way too complicated to put into the Rich Text Editor, so I created a Template for this email, and set the email node to use that template.
I then used the umbraco.Library.RenderTemplate method to create the email body. This worked really well and sends out the email exactly as expected.
Unfortuanately after implementing this some strange errors started occurring. I think these error are occurring because after calling RenderTemplate, UmbracoContext.Current returns the Email node rather than the actual page that was being rendered before sending the email. RenderTemplate seems to change the CurrentPage.
Am I misusing RenderTemplate? Is there another way to render a node programmatically?
Ideally, the email would not be sent from the page render but put on a queue and processed by another process. There is no plans or time for this at the moment.
Thanks
Dallas
See issue #21983 wich is not closed as of today. Also read this old forum thread. At the moment, RenderTemplate does seem to change CurrentPage.
is working on a reply...