Try our conversational search powered by Generative AI!

Resolving custom urls in XHTMLString


I know EpiServer handles internal links in XHTML strin to expand links like ~/link/d9651bd2ab2a44afb74b550b4eb2acfc.aspx to meaningful URLS on runtime http://localhost:57906/en/alloy-meet/

We will be allowing our editors to add links to documents stored in external system, and we will be putting in the url something like extSystem://<document-id> in the markup (raw value in DB) and when rendering, it should be changed to working, friendly URL like:<document-id>

So I'm looking for a way to identify and parse the links when XHTMLString is rendered. Any place where I could hook? Service to overrride, extend?

Edited, Apr 30, 2020 13:09

Not very elegant perhaps, but you could hook into the PublishingContent event. Loop through all XhtmlString-properties, swapping out extSystem://<document-id> for your actual URL.

Apr 30, 2020 19:56

I would recommend creating a new toolbar icon within tinymce. That way you will have the full link straight away, you could even integrate a search of the document management system to return the document id and then create the link. There are a lot of examples of adding a new button to tinymce in Episerver if you have a google.

May 01, 2020 0:22

I second Paul's answer.

In fact, you could extend the Episever link editor with a field where the editor just adds the document IDthen the full external URL is returned. I just wrote a blog post which did some similar with telephone numbers.

I was thinking you could also extend the UrlResolver but I don't think that'll work anyway because it looks like Epi are using an extension method (GetShortcutAwareUrl) when rendering an XhtmlString.

May 01, 2020 15:18

I actually went that path extending the URL field editor, which works fine. I initially went with custom scheme, becasue it allows me easily determine if the link is a true external link OR just link to another place in the system.

I'll extend that behavior to store full link in the field and make sure that I can properly distinguish my links vs external links.

While I have you all here, maybe you could also have a look into my other thread: Dijt FilteringSelect and EpiServer rest store issues

I hooked up RestStore with dijit/FilertingSelect and I've ran into some issues.

May 04, 2020 6:59
* 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.