White Lable Web-Site Hyperlinks

Vote:
 

Our Requirement – White Label Web-Site

To have multiple web-sites all utilising shared content.

Proposed Solution

To have multiple sites in EPiServer Entriprise Edition with each site using “Fetch Data” to retrieve content from the master-site.

Each site is then branded differently.

Issue

An editor updates a page (Page A) on the master-site to have a hyperlink to another page (Page B) on the master-site. When this link is fetched into one of the white labelled sites the link goes to the page on the master-site (Page B) rather than what is wanted – the version of the page on the white labelled site.

Possible Solutions

I am considering coding a plug-in (IDynamicContent) that the editor would use instead of the standard EPiServer hyperlink tool. This plug-in would create a relative URL at edit-time. This should mean that the link should work as required in the White Labelled sites.

Has anyone done something similar or get an alternative solution? Is there something in the Enterprise Edition (we haven’t got our Enterprise license yet) that will do this for us?

Any help would be appreciated.

p.s. this is all being done in CMS6.

Thank you

Michael

#41972
Aug 05, 2010 11:38
Vote:
 

We just did this exact same thing -- 86 sites running on the same install, all pulling content from a central set of pages (stored right under the root node).

Are all the sites going to have the exact same content?  Will all pages in the master site exist in all the multiple, white-labeled sites?

I wouldn't create this relative link at edit time, I'd do it at render time.  Hook into HTML rewriting, and catch all the A tags going to the master site, and rewrite them there to remove the domain.  You could probably do it in a dozen lines of code.

#42025
Edited, Aug 06, 2010 0:35
Vote:
 

Each site will have the same page structure with 99% of the content exactly the same. There will be a couple of page properties that will be overwritten by the editors.

Agree that this should be done at render and not edit. After posting this I looked at ways of doing just that.

First I looked at using a Control Adapter (I am a big fan of Control Adapters see recent issue and solution) that I hooked into the HtmlAnchor but this did not fire when expected - propbably because the html anchor tags are being rendered as a string not by creating a control.

I then looked at the possibility of coding a new version of the PropertyXhtmlStringControl - haven't got very far on this yet.

Could you explain / point me at an example or article of "hook into HTML rewriting".

Probably worth noting I am very new to EPiServer - this is my first project!

Thank you for any help you can give.

Michael.

 

 

#42030
Aug 06, 2010 10:01
Vote:
 

Mike:

This code has literally been through about 10 seconds of testing, but it worked for me.  Compile this into your project and test throughly.

Deane

 

using System.Text.RegularExpressions;
using System.Web;
using EPiServer;
using EPiServer.Core;
using EPiServer.PlugIn;
using EPiServer.Web;
using System.Xml;
using System;

namespace Bancorp.Library.EPiServer.Plugins
{
    /// <summary>
    /// Remove the domain from links
    /// </summary>
    [PagePlugIn()]
    public class ForceRelativeLinks
    {
        public static string oldDomain = "http://www.domain.com";

        public static void Initialize(int optionFlag)
        {
            HtmlRewriteToExternal.HtmlRewriteInit += HtmlRewriteToExternal_HtmlRewriteInit;
        }

        static private void HtmlRewriteToExternal_HtmlRewriteInit(object sender, HtmlRewriteEventArgs e)
        {
            e.RewritePipe.HtmlRewriteValue += HtmlRewriteValueEventHandler;
        }

        /// <summary>
        /// This runs on every element parse...
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        static private void HtmlRewriteValueEventHandler(object sender, HtmlRewriteEventArgs e)
        {
            //I stole this conditional expression from this page: http://sdk.episerver.com/library/cms6/Developers%20Guide/Advanced%20Features/Tutorials/HTML%20Rewriting%20Functionality.htm#Rewriting%20the%20HTML%20-%20HtmlRewriteValueEventHandler
            if (e.ElementType == HtmlRewritePipe.ElementTypes.A && e.NodeType == XmlNodeType.Attribute && string.Compare(e.Name, "href", StringComparison.OrdinalIgnoreCase) == 0)
            {
                e.ValueBuilder.Replace(oldDomain, String.Empty);
            }

        }


      
    }
}
    
#42059
Aug 06, 2010 14:41
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.