Get page from TinyMCE URL

Member since: 2010

Hey, I'm trying to get a page from TinyMCE content URL-s. Sometimes, the HTML code for them is ie. "/link/5e2e383dc27944599568d46b085d62d2.aspx" and sometimes, URL is a an Edit mode URL, ie. /EPiServer/CMS/Content/om-fonus/demo-page,,124/. It seems that the edit-mode URL is displayed on page load, but once you change the page selection, you get the /link/xxxx.aspx.

The following code works for the classic link, but not in the case of edit-mode:

public static PageData GetPageFromClassicUrl(string classicUrl)
        {
            string linkUrl;
            if (PermanentLinkMapStore.TryToMapped(classicUrl, out linkUrl))
            {
                var pageReference = PageReference.ParseUrl(linkUrl);

                if (!PageReference.IsNullOrEmpty(pageReference))
                {
                    var page = DataFactory.Instance.GetPage(pageReference, LanguageSelector.AutoDetect());
                    return page;
                }
            }
            return null;
        }

    

Does anyone know how to get the page from the latter (edit-mode) or should I parse the string and get the ID between a comma and a slash?

Thx!

#84315 Mar 31, 2014 15:20
  • Member since: 2004

    I have not tried this myself but could you not use UrlResolver.Route(UrlBuilder, ContextMode.Edit)? I think it should handle both url formats.

    #84349 Apr 01, 2014 9:59