Quick and clean solution:
- Create a new template (called "Folder with default item" or whatever you prefer), inheriting from the standard Folder template
- Add a field to your custom folder (e.g. Droptree, and set the
Source
of the field to query:./*
)
- Add new
httpRequestBegin
processor after ItemResolver
. Use code (not tested - try and fix if needed):
public class DefaultItemResolver : HttpRequestProcessor
{
public override void Process(HttpRequestArgs args)
{
if (!Context.PageMode.IsNormal || Context.Item == null || Context.Item.TemplateID != DefaultItemFolderTemplateId)
{
return;
}
Item target = null;
if (!string.IsNullOrEmpty(Context.Item[DefaultItemFieldIdOrName]))
{
target = Context.Item.Database.GetItem(Context.Item[DefaultItemFieldIdOrName]);
}
Context.Item = target;
}
}
Code above return 404 if default item is not selected. If you want to show folder item instead, check if target
is not null before assigning it to Context.Item
.