A feature I use heavily in Umbraco, and one I've missed in
EPiServer CMS, is the use of icons for different page types in the
tree. Although this functionality has been around for a while using
PageTreeIcons, when using PageTypeBuilder it can be quite cumbersome to
maintain a configuration with PageTypeId's, when we want to move
away from that.
Heavily inspired (and with some borrowing), I've converted the
PageTreeIcons project to a collection of attributes that you can
use to alter the icons for page types and properties. It's still an
early draft, but it works.
This way, it's really easy to keep track of the icons for your
properties, and there's no need to keep an extra section in your
web.config. Some features have been removed, since EPiServer CMS 6
already contains some of the functionality (i.e the
PageLinkTypeHandler).
It's applied like this, on page types
[PageTypeIcon("~/UI/Images/PageTreeIcons/page.png", typeof(ContentPage))]
[PageType(AvailablePageTypes = new[] { typeof(ContentPage) },
Filename = "~/UI/Pages/ContentPage.aspx",
SortOrder = 20,
Name = "[Public] ContentPage",
DefaultSortIndex = 100,
Description = "An ordinary content page.")]
public class ContentPage : PageTypeBuilder.TypedPageData { ... }
and like this, on a property
[PropertyEmptyIcon("~/UI/Images/PageTreeIcons/warning.png",
"/pagetreeicons/property/missingkeywords",
"MetaKeywords",
new [] { typeof(BaseModule), typeof(ModuleContainer), typeof(Contact) })]
[PageTypeProperty(EditCaption = "Keywords",
HelpText = "A comma-separated string containing keywords used for this page.",
Searchable = true,
UniqueValuePerLanguage = true,
Type = typeof(PropertyString),
SortOrder = 10)]
public virtual string MetaKeywords {
get;
set;
}
Again, kudos to Henrik Nyström, http://thisisnothing.wordpress.com/, for
writing this in the first place.
Please let me know if you have any comments, improvements, or
questions.
Download the code
here.
Don't have any icons? Try FamFamFam Silk!