Having the possibility to upload files into EPiServer Community Clubs has internally been a highly requested feature on our Intranet site. Since the EPiServer.FileManger that you see in our Demo templates are based on EPiServer CMS pages and files stored into the current page folder that will not work for Community clubs that are not based on pages.
Well after some discussion with my colleagues the solution was quite simple; Combine how EPiServer Blog uploads file with the Workroom File Manager web control.
I choose to copy the EPiCheckBox class and changed the namespace to EPiServer.Templates.RelatePlus.Classes.
EPiServer Blog uploads its files into Global Files folder if not reconfigured in web.config. There it creates a xmlrpc folder and from there the tree structure is; PageID, Year, Month, Day.
My strategy was similar. The File Manager requests a RootFolder Path, so instead of a xmlrpc folder I defined a “ClubFiles” folder and beneath it a folder for each club based on ClubId, but I skipped the date folders. Similar to blogs which worked with PageID.
The code then,
2:/// Gets or sets the file folder root.
4:/// <value>Path to root folder for files.</value>
11: _fileFolderRoot = GetVPPFolder();
18:// stolen from how episerver.blogs handle file uploads, changed blog page id to use club id
The File Manager is built for EPiServer CMS Pages and the bread crumb control expects the files to be in the page’s directory, where it gets the page owner and displays the Page Name. Well this will not work for Community clubs, so we need to change it to get the Club Name of that folder.
My current solution is a quick hack where it tries to Parse the Folder name, which is the club id and then get that club. Anyhow, in the usercontrol HeadingContent we modify the method AppendBreadCrumbs to:
2:/// Appends the cookie crumb links to the control supplied as targetControl.
4:/// <param name="currentDirectory">The current directory.</param>
5:/// <param name="targetControl">The target control to append cookie crumb links to.</param>
6:privatevoid AppendBreadCrumbs(UnifiedDirectory currentDirectory, Control targetControl)
43: b.Command += new CommandEventHandler(RaiseCommand);
Then the “final” solution looks like this,
And in Admin mode, File Management:
Then you’re done. Now check in your code, get a cup of coffee and let the GUI dude fix the layout stuff.
Something that I haven’t done yet but I should is to create my own Virtual path provider. Inherit fromEPiServers VPP, override the QueryAccess method and check that the access rights of the files match the current users club access rights. Might be a different blog post.
By the way, I haven’t tested this on live site yet and might have forgotten something. Comments and feedback is appreciated.