Yesterday I wrote about “All the small things” that make SiteFactory CMS a great system. In this post you will read about PageTypes and Url Rewriting in SiteFactory CMS.
PageTypes
PageTypes is a brand new feature that we released last week. With PageTypes you can define exactly what a Page Object is. By default a PageType is a class Page (web page), but you can create new PageTypes e. g. News post, Calendar Post or a Customer Reference. Well, pretty much whatever you want it to be.
In the text below I will refer to the “Page Object”, which must not be confused with the Page class (System.Web.UI.Page). Our “Page Object” is referred to as a web page in the System.
Example:
You want to build a classic News Administration, so you create a PageType called “NewsPost”, then you create your module that handles the administration of your news posts. When it’s time to create a News Post you simply call the SiteFactory Core telling it you want to create a Page Object. The Core will return a new Page-ID that you connect to your Module.

What this example doesn’t show is the the data you must send to the function. Before you receive a Page-ID a Controller checks if it’s ok to create the Page Object (based on the data you provide).
In most cases you re-use the Page Object Fields for your Modules data. Since the Page Object has a great amount of fields (like Title, Url Rewrite Key/Alias, Excerpt, Text Content, Publish On date, Unpublish On date, Search Engine Fields and many other) this is in many cases enough for your module. But you still have full availability to store whatever fields and/or data you want in your module that is connected to the Page Object.
Why PageTypes are perfect
The Page Objects are tightly integrated with our Url Rewriting Engine so you get pretty urls without having to write your own code or rules to make it work. The full url of the page can be returned quickly by the Page Object:

As I wrote earlier, the Page Object holds many Fields that you can re-use for your Module/Page Type. And code re-use is always good.
You can create as many PageTypes you want. The possibilities are endless.
The original idea for our PageTypes comes from our great colleagues Alexander & Kim that surprised us with a custom implementation of PageTypes in an existing SiteFactory CMS solution. So after a developer meeting we all agreed that this was our top next feature for our product. So only about a week later it was fully incorporated into the source code and was soon after pushed out to our customers.
Url Rewriting
In the spring of 2008 we decided to include Url Rewriting in SiteFactory CMS. We did this in the final minor release of SiteFactory 2 (2.1.1). Soon after we started developing SiteFactory 3.0 where we extended the capabilities of Url Rewriting.
In the Configuration files you can choose between two types of Url Rewrite rules. One works straight of with IIS 6.0 (without custom configuration in the IIS). The other one uses Url Rewrite Module for IIS 7.
IIS 6.0
When using IIS 6.0 you must have a file extension for your page (e. g. http://www.domain.com/products/product-1.aspx). You can however choose (almost) any file extension, so you don’t have to use .aspx.
IIS 7.0
This is most commonly used when we deploy projects. Here you can build your own rules and you don’t need the file extension (e. g. http://www.domain.com/products/product-1/).
Setting it up
First you must make some simple configurations in the Settings Configuration file.
As you can see you have the ability to not use Url Rewriting. But the url will look like this http://www.domain.com/default.aspx?pageId=123. Ugly, right?
Depending on which version of IIS you will use we provide two Web Configuration files where the rules are configured.

All the basic rules that you need are already configured in these files.
Implementation
If you want to create custom lists with Page Objects you can always get the url (and other data) from the Page Object.
Very simple Repeater implementation.
Url Rewrite any string
With our Extension Methods you can format any string making it valid for Url Rewriting.

Closing comments
I hope this shows you how easy it is to work with PageTypes and Url Rewriting in SiteFactory CMS.
I haven’t yet decided what to write about in my next part of “The Power of SiteFactory CMS”. If you have anything you want me to write about, post a comment.