FriendlyUrl in content

Vote:
 

Hi

We're running an EpiServer CMS 5.1.422.2.

A lot of our content, we're ouputting as xml
We're using FriendyUrl:s, and it works great ( except for the below of course ;-( )

To accomplish this we are doing something like the below on the different  pages

void override void OnLoad(param) {

Response.ContentType = "text/xml";
Response.Clear();

XmlDocument xmlDoc = new XmlDocument();
// some code to build up the xml doc
string strHtmlEditorContent = CurrentPage["MainBody"] as string; // this html
// create CDATA section with the strHtmlEditorContent

xmlDoc.Save(Response.OutputStream);

}

Our problem is that links <a href ... attributes are not transformed to FriendlyUrl:s, but if we output the same CurrentPage["MainBody"] in html, for example to an <asp:Literal ... it transform the url:s to FriendlyUrl:s. In other words, it automatically transforms the urls during the rendering of the page/control.
Is there any way to force EpiServer to tranform a PropertyLongString / Editor property, its content links to FriendlyUrl:s ?

Thanks !

 

 

#23622
Sep 11, 2008 9:51
Vote:
 

Yes. You have to convert trigger rewrite manually:

 

HtmlRewriteToExternal htmlRewriter = Global.UrlRewriteProvider.GetHtmlRewriter();  strHtmlEditorContent = htmlRewriter.RewriteString(UrlInternal, UrlExternal, System.Text.Encoding.UTF8, strHtmlEditorContent);

 

For single URLs, Call ConvertToExternal method.

 

Global.UrlRewriteProvider.ConvertToExternal(UrlExternal, pageData.PageLink, System.Text.Encoding.UTF8); 

 

/Fredrik

#23629
Sep 11, 2008 11:32
Vote:
 

Hi!

I tried this, the only way I did not get runtime error, but the href was not correct:

What am I doing wrong ?

// pd is a PageData object
UrlBuilder urlExt = new UrlBuilder(EPiServer.Configuration.Settings.Instance.SiteUrl);
UrlBuilder url = new UrlBuilder(pd.LinkURL);
EPiServer.Web.HtmlRewriteToExternal htmlRewriter = Global.UrlRewriteProvider.GetHtmlRewriter();
string strNewString = htmlRewriter.RewriteString(urlExt, url, System.Text.Encoding.UTF8, strHtmlEditorContent);

Can you provide me with an example of what the UrlInternal / UrlExternal could be ?

Thanks

#23648
Sep 11, 2008 17:13
Vote:
 

This is the way I use to make the links to work in an external rss reader with EPiServer CMS 5 

To start with I make all links and image urls complete with an regex inserting SiteURL before them.

Then I do this.

UrlBuilder url = new UrlBuilder(page.LinkURL);  EPiServer.Global.UrlRewriteProvider.ConvertToExternal(url, page.PageLink, System.Text.UTF8Encoding.UTF8);  EPiServer.Global.UrlRewriteProvider.GetHtmlRewriter().RewriteString(new UrlBuilder(page.LinkURL), url, System.Text.UTF8Encoding.UTF8, your_string_here); 
#23659
Sep 11, 2008 23:57
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.