Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

Anders Hattestad
May 13, 2011
(3 votes)

Mount EPiServer Community Club as part of the page structure

imageIn a intranet project I’m working on we are going to use Community for collaboration between the employees. But we needed to mix one club and other EPiServer pages together. Community out of the box gives us 1 page branch that shows all the clubs.

So what I wanted was to mount the original club structure as a Page Provider structure inside my other content.




I have done some work before that take on substructure and mount is it as a sub branch in my blog post:

PageProviders and DDS, a match from heaven…

The blog only got a 1 rating, but the concept is easy to use, and can be used in many different ways. Here I’m going to use that to mount the Club structure in different places.


So I made myself a page type AttachClubFolderPageType and if you create that page I added a EditPanel plugin that give you the option to either create a new club or attach yourself to an existing club. This page type could default be a system page, before it become a normal page when its mounted.


The name and intro field of the club will be this parents pagename and main intro. In this case Fagområde D.

After you have created the club you can mount the page provider. This can be done by code as shown by Alan in this blog post.  The status of the mount and the connection between the club and the mount page will be preserved in a dynamic data store table.


The ClubFolder page will be changed so it redirects to Home.

So far so good. But the Community templates uses a request variable clubID to show the current clubs values. So I needed to add a request parameter depending on where in the structure on was.

I first started to make my self a new Friendly URL rewriter, but discovered that there are events that one can attach to to do small stuff like this. This is create news, since its troublesome to make your own rewriter for easy stuff like this. (Thank you who ever you are that made this! Smile )

Code Snippet
  1. [EPiServer.Framework.ModuleDependency(typeof(PageTypeBuilder.Initializer))]
  2. public class AttachEvents : IInitializableModule
  3. {
  4.     #region IInitializableModule Members
  5.     public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context)
  6.     {
  7.         TrackPageChanged.Current.CommentAdded += new PageEventHandler(Current_CommentAdded);
  8.         Global.UrlRewriteProvider.ConvertedToInternal += new EventHandler<EPiServer.Web.UrlRewriteEventArgs>(UrlRewriteProvider_ConvertedToInternal);
  9.         ClubvsPage.MountActive();
  10.     }
  11.     void UrlRewriteProvider_ConvertedToInternal(object sender, EPiServer.Web.UrlRewriteEventArgs e)
  12.     {
  13.         var pageRef = e.Internal as PageReference;
  14.         if (pageRef != null)
  15.         {
  16.             if (!e.Url.Query.Contains("clubID") && e.Url.QueryCollection["clubID"] == null)
  17.             {
  18.                 if (!string.IsNullOrEmpty(pageRef.RemoteSite) && pageRef.RemoteSite.StartsWith("ClubID"))
  19.                 {
  21.                     e.Url.QueryCollection.Add("clubID", pageRef.RemoteSite.Replace("ClubID", ""));
  23.                 }
  24.             }
  25.         }
  26.     }


So I attached myself to ConvertedToInternal and added the clubID based on the name of the Page Provider. The I could go to home and see club 4’s club home page. But I also needed to make all links to home, wall, image etc point to my page provider page. To archive this I needed to change some of the extension methods in the Community templates like this:

Code Snippet
  1. public static Uri GetClubUri(this Club club)
  2. {
  3.     return ClubvsPage.GetClubUrl(club, Pages.Base.PageBase.ClubHomePage);
  4.     //UrlBuilder url = new UrlBuilder(Pages.Base.PageBase.ClubHomePage.LinkURL);
  5.     //url.QueryCollection.Add("clubId", club.ID.ToString());
  7.     //if (UrlRewriteProvider.IsFurlEnabled)
  8.     //{
  9.     //    Global.UrlRewriteProvider.ConvertToExternal(url, Pages.Base.PageBase.ClubHomePage.PageLink, Encoding.UTF8);
  10.     //}
  12.     //return url.Uri;
  13. }

So it pointed to a method that checked if this club was mounted and what page provider page it pointed to.

After that was done, all the links to this club or other part of the club pages was rerouted to my page provider pages.

Then I only needed a method to find what club (if any) a normal page was connected to.

So in user controls I wanted to use the current club I’m using this method

Code Snippet
  1. int _currentClubId = -1;
  2. public Club CurrentClub
  3. {
  4.     get
  5.     {
  6.         if (_currentClubId==-1)
  7.         {
  8.             int currentClubId = 0;
  9.             if (!int.TryParse(Request.QueryString["clubId"], out currentClubId))
  10.             {
  11.                 var tmpP=CurrentPage;
  12.                 while (tmpP != null)
  13.                 {
  14.                     if (!tmpP.PageLink.IsRemote())
  15.                     {
  16.                         currentClubId = ClubvsPage.GetClubForPage(tmpP.PageLink.ID);
  17.                         if (currentClubId > 0)
  18.                             break;
  19.                     }
  20.                     if (PageReference.IsNullOrEmpty(tmpP.ParentLink))
  21.                         break;
  22.                     tmpP = EPiServer.DataFactory.Instance.GetPage(tmpP.ParentLink);
  23.                 }
  24.             }
  25.             _currentClubId = currentClubId;
  26.         }
  27.         if (_currentClubId>0)
  28.             return ClubHandler.Instance.GetClub(_currentClubId);
  29.         return null;
  30.     }
  31. }

which basically move up to it finds the owner of the clubFolder page and returns the current club, else it returns null.

so if I’m in this location


I can get the members of the club and display them like this



I don’t know what happens if I mount 100+ of page providers. There could be some performance issues. But as far as I can tell I haven't experienced any of that yet. Keep my fingers crossed Smile.

The code is uploaded to the code section here

but at the moment there is an error uploading, so it’s not there yet.

May 13, 2011


Please login to comment.
Latest blogs
Stop Managing Humans in Your CMS

Too many times, a content management system becomes a people management system. Meaning, an organization uses the CMS to manage all the information...

Deane Barker | Nov 30, 2023

A day in the life of an Optimizely Developer - Optimizely CMS 12: The advantages and considerations when exploring an upgrade

GRAHAM CARR - LEAD .NET DEVELOPER, 28 Nov 2023 In 2022, Optimizely released CMS 12 as part of its ongoing evolution of the platform to help provide...

Graham Carr | Nov 28, 2023

A day in the life of an Optimizely Developer - OptiUKNorth Meetup January 2024

It's time for another UK North Optimizely meet up! After the success of the last one, Ibrar Hussain (26) and Paul Gruffydd (Kin + Carta) will be...

Graham Carr | Nov 28, 2023

Publish content to Optimizely CMS using a custom GPT from OpenAI 🤖

Do you find the traditional editor interface complicated and cluttered? Would you like an editorial AI assistant you can chat with? You can!

Tomas Hensrud Gulla | Nov 28, 2023 | Syndicated blog