Monday, September 08, 2008

Sharepoint MOSS 2007: Custom Redirect Page Content Type

Once you start creating custom content types and use those for filters in a CQWP, you might want to include redirect pages in your CQWP results. That means you'll need to setup a new Redirect Page Content Type in your content type hierarchy, but you'll assign it to the Redirect Page Template created by the MOSS Publishing Feature.

First, I'll assume you've created a site using one of the MOSS publishing site templates. If not, I recommend you create a new collection in your development environment to try this out.

Lets assume that you already have a few Custom Content Types. For my publishing site, I have the following hierarchy:

  • Bryan Custom

    • Bryan Custom - Basic Web Page

    • Bryan Custom - Document

    • Bryan Custom - Picture

I do this because I can then search my whole collection for any content type who's parent is "Bryan Custom" and then display any base metadata I've defined in the Parent Content Type "Bryan Custom".

Now I want to do the same with a Redirect page. We will need to create a new content type "Bryan Custom - Redirect Page" and make its parent "Bryan Custom" so that it inherits all the base metadata I need. Now the key to making the redirect functionality work - we then create a new redirect Page Template and associate that template with our new Content Type. Here's how:

1) Create a new Custom Content Type from the Site Collection Settings. Under "Galleries->Site Content Types" select "Create" Give your new type a meaningful name, Like "Bryan Custom - Redirect Page". And be sure to set the parent content type to "Bryan Custom". Assign it to the group you want, then click "OK".

2) Edit your new content type then click "Add from existing site columns." Change the "Select columns from" dropdown to "Page Layout Columns" and add "Redirect URL" to the list of columns to add to the Content Type. Click OK. This column is required by the Redirect Page Template that we'll create in the next step.

3) Open SharePoint Designer 2007 and login to your site collection. Browse to \_catalogs\masterpages\ and make a copy of RedirectPageLayout.aspx. (NOTE: you should never-ever-ever modify an out-of-the-box SharePoint template! Always make a copy and modify the copy!) Rename our copy to BryanCustomRedirectPageLayout.aspx. At this point, you can close SharePoint Desinger.

4) Back to the Site Collection Settings page, browse to "Galleries->Master pages and page layouts". Find BryanCustomRedirectPageLayout.aspx in the list and edit its properties. Under "Associated Content Type" change the Content Type to be the new content type we created "Bryan Custom - Redirect Page". Click OK, then checkin/publish/approve the new page template.

5) Again from the Collection Settings page, browse to "Look and Feel->Page Layouts and Site Templates". Under "Page Layouts" make sure you allow the new page template to be used in the site (in case you are specifying a limited number of useable page templates like I am).

Thats it! Now when you create a new page, you can select a page type of "Bryan Custom - Redirect Page". Then you need to edit the properties of that page and set the Redirect URL property, as well as any other custom properties you need for this piece of content to show up in your CQWP.

1 comment:

Unknown said...

Unbelieveably helpful!!! You dont know how much time I spent trying to figure this out!! Thank you so much!