Thanks for your answers, will try the dandrayne solutions in a macro.
Bob, the problem is that the urls are included in the text I received from the tidy editor so I need something like a find/replace or a system to change the wysiwyg comportment to always use full url...
I wouldn't be certain that base href will survive in online mail clients (gmail etc), as they strip out any html that could interfere with the surrounding page.
I have test your solution dandrayne, it works only for url that you type your self wihtout selecting a page.
If you select an existing page your have an url like this: href="http://www.yoururl.com/{localLink:1356}
So It finally wasn't the solution. The best solution would be something that replace all urls after the Render without removing the replacement of localLink...
Get absolute URL on href src for newsletter template
Hello
I have made a newsletter template. I use the generated html from umbraco and then I copy/pasted it to a newsletter software.
I am looking for a way to transform on the fly all relatives urls (in freetext editor) to an absolute one (with http://www...)
It's possible to override the render and execute some RegEx or replace like this but it removes the nice url transformation.
<script runat="server">
protected override void Render(HtmlTextWriter writer)
{
System.Text.StringBuilder htmlString = new StringBuilder(); // this will hold the string
System.IO.StringWriter stringWriter = new System.IO.StringWriter(htmlString);
System.Web.UI.HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
base.Render(htmlWriter);
htmlWriter.Flush();
writer.Write(ReplaceUrl(stringWriter.ToString()));
}
private string ReplaceUrl(string p)
{
string url = "http://www.gondwana-dmcs.net";
p = p.Replace("href=\"/", "href=\""+url+"/");
return p;
}
</script>
Do you have an idea to have all absolute url everywhere? Or a system to make the exportation to a newsletter tool easier ?
Thanks a lot!
http://our.umbraco.org/forum/developers/extending-umbraco/4589-Overriding-umbraco-locallink-parser
The previous post wasn't a good solution. Anybody has an idea to accomplish this ? Thanks
You may be able to try a little replace as you output the values? Hacky but should work
Dan
this simple line of xslt gives you the full url of the current page....
<xsl:value-of select="concat('http://', umbraco.library:RequestServerVariables('SERVER_NAME'), umbraco.library:NiceUrl($currentPage/@id))"/>so, i imagine you could use that as a start...
of course, there is also my favorite... jquery :)
http://projects.allmarkedup.com/jquery_url_parser/
Thanks for your answers, will try the dandrayne solutions in a macro.
Bob, the problem is that the urls are included in the text I received from the tidy editor so I need something like a find/replace or a system to change the wysiwyg comportment to always use full url...
Any other ideas?
what about setting a <base/> attribute in your template?
<BASE HREF="http://www.yourdomain.com" TARGET="_top">
not sure that helps for the mail being forwarded... but would do the trick.
I have also been using the <base/> element for this. And it seemed to be working fine even though I'm not sure that it's 100% bulletproof though.
/Jan
i think the base tag fails when the message is forwarded... some clients strip it... i think...
Yes, actually the best thing will be a check and replace after the render of the page on each HREF and SRC to be sure.
And not on all website, only in some template like a newsletter one.
So if you have a lot of different properties/field you don't have to add the dandrayne macro on each field....
can you not just use something like:
I wouldn't be certain that base href will survive in online mail clients (gmail etc), as they strip out any html that could interfere with the surrounding page.
I have test your solution dandrayne, it works only for url that you type your self wihtout selecting a page.
If you select an existing page your have an url like this: href="http://www.yoururl.com/{localLink:1356}
So It finally wasn't the solution. The best solution would be something that replace all urls after the Render without removing the replacement of localLink...
Any ideas ?
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.