Redirecting container page type
I often find it is necessary to use pages just to structure other pages in a site. Many of you have probably at one time or another had a page in your web site root called [Footer menu] or something similar. Editors do this too, to group or tuck away a number of pages that, for example, don’t fit into the menu structure.
Generally you want those container pages to show as little as possible. If some visitor end up on such a page, for example by erasing the last part of the URL when looking at www.site.com/Footer/Contacts if there were such a page, they would most likely be looking at a pretty empty (ugly, boring…) page.
Using the built-in redirect
So you say “hey, just use the built-in feature to redirect the container to some useful page”. Sure, that works fine. But it’s likely editors will forget to do it from time to time. A different approach is to create a special container page type, and build the redirect mechanism into the page template. I think editors are more likely to remember to use the special page type when creating a container.
The redirecting container page type
I have constructed several different variants of this page type. This is a simple one.
If the page is viewed in edit mode it does not redirect, it merely displays a message (in the form of a link) to where it would redirect in view mode. If the redirect target property is not set it simply redirects to it’s parent.
Some variations of the concept I have used:
- Make the redirect target property mandatory. Even simpler, but might confuse editors because they feel they must find something meaningful to redirect it to.
- Use a (possibly configurable) delay before redirecting, and display a “you are now being redirected to…” message. This gives your framework and it’s visitor statistics scripts etc. the possibility to load. The delayed redirect can be accomplished by the meta http-equiv="refresh" directive with delay and url parameters.
- Use PropertyUrl rather than PropertyPageReference for the redirect property. This obviously makes it possible to redirect to pages outside the site, but beware that it makes it more difficult to detect infinite loops.