Controlling YetAnotherForum from inside Sitecore

One of my recent projects has been to run YetAnotherForum (YAF) inside a Sitecore website (read this earlier post). The changed YAF source can be found as an open source project at http://trac.sitecore.net/YAFIntegration.

Now the project has been expanded with a Sitecore package that allows you to control the behaviour of the YAF control from inside Sitecore. The optional package consists of a custom field and a sublayout that allows you to set which board, group or forum that YAF should display.

When placing the custom field on a page, it becomes possible to select which board, group or forum that the sublayout must display:

Displaying boards, groups and forums from YAF

Displaying boards, groups and forums from YAF

The sublayout uses this data to display whatever is chosen:

This example shows how YAF used the information from the dropdown to display one forum only.

This example shows how YAF used the information from the dropdown to display one forum only.

The function gives you the possibility to display one forum on one Sitecore page, and another forum on another page. Or displaying all forums on one page, one group on another page, and one forum on a third page. And so on and so on. 

The feature is part of the optional Sitecore package included in the YAFIntegration project. Read more about the package here: http://trac.sitecore.net/YAFIntegration/wiki/Optional_Package

Running YetAnotherForum inside Sitecore

As I mentioned in the previous post, YetAnotherForum (YAF) cannot run inside Sitecore unless the code base of YAF is changed. So that’s exactly what I did. 

YetAnotherForum running in Sitecore

YetAnotherForum running in Sitecore

 You can find the changed YAF codebase in Sitecores trac:

http://trac.sitecore.net/YAFIntegration

So what does the code do? It allows you to run YAF in a Sitecore layout, on any Sitecore page you wish, using Sitecore extranet (or any other domain) users.

But let’s begin with the beginning. In order to run YAF inside a Sitecore web site at all, major changes are required in the web.config of your website. Basically it requires you to merge the YAF config files with the Sitecore config files. I have provided a sample web.config where I have merged the 2 config files together, as well as a complete description of all changes required.

After you have merged the web.configs, you will need to build the code and apply the code and binaries to the Sitecore solution. The documentation will help you with this.

What code changes have been made then? Since Sitecore and YAF both uses standard .net security providers, changes are relatively small (although widespread). YAF is capable of digesting Sitecore members and roles (users and groups) directly. But since the .net platform only allows one profile provider, the YAF profile provider need to inherit from Sitecore’s profile.

Another change are also implemented: The standard .net security model expects all users to have access to all parts of the website. Sitecore cannot live with that, as some users can access the client, and other can access the extranet. Sitecore deals with this issue in a brilliant, simple way, by prefixing users with the Sitecore domain name. So when Sitecore returns the Anonymous user, the username is extranet\Anonymous. To avoid displaying user names prefixed with the current domain name in YAF, the code wraps the MembershipUser class to ensure that only users from the current domain (usually extranet) can log into YAF, and that the domain name is not displayed in the username.

Users from the current Sitecore domain is displayed in YAF.

Users from the current Sitecore domain is displayed in YAF.

Since YAF is licensed under the GNU public license, so is this code. This means that you can use, change and share the code and any changes you make, as you wish.

 

Follow

Get every new post delivered to your Inbox.

Join 92 other followers