Friday, January 19, 2007

Sitecore 5.3: Adding values to the Properties view in the Content Manager

As seen on SDN5 Forum there was a question about properties for the selected item, and specifically to see a count of how many children that item had. Unfortunately that property isn't shown by default, but, you can always add it yourself (gotta l ove sitecore). Here's what you do:
  • Locate SystemMenu Information.xml (it's in sitecore\shell\Applications\Content Manager\Galleries\SystemMenu)
  • Add the following two lines right beneath "<Border def:ID="Template" />"
<Literal GridPanel.Class="scKey" Text="Children:"/> <Literal GridPanel.Class="scValue" def:ID="Children" Text='${Sitecore.UIUtil.GetItemFromQueryString(Sitecore.Context.Database)==null?"unable to list":Sitecore.StringUtil.GetString(Sitecore.UIUtil.GetItemFromQueryString(Sitecore.Context.Database).Children.Count,"unknown").ToString()}' />

That's pretty much it, now you'll get a count of how many children (if any) that exist on a selected item.

"Hacking" sitecore can sometimes really be that simple, ain't it awesome? :)

EDIT: Actually you probably want to swap the database part for something else to make it more robust, either get the DB by name or through the use of Sitecore.Context.ContentDatabase instead.

P.

1 comment:

Anonymous said...

This is great Peter. Hmmm this should be an article, or perhaps a scrapbook article.