I prepared a small improvement for Content Selector property. Standard property is a label displaying selected content name and a button used to selecting a content.
ContentSelector - property
After editor selects an item it’s hard to determinate the ID of the selected content. To do this you need to open the content tree dialog once again, hover over selected tree node and check the tool-tip value. You may copy ID, replace it in the browser URL and edit the page… It’s really time consuming.
ContentSelector - dialog

With small development effort we could improve the property and make this process easier.
We will implement two new features:

  • Label tooltip will be extended – it will show the name of the content , but also content ID and content type
  • Double click on label should change the editing context

Dojo widget

The client editor will reuse most of the functionalities from standard content selector (“epi-cms/widget/ContentSelector”). We will use it as a base class. The _updateDisplayNode method has content parameter object which contains all necessary information. We will use it to get content ID and type name.
There is also contentUri property containing edit mode URL. It can be used to redirect page to edit mode. Changing the context will be done by publishing “/epi/shell/context/request” event.

Since we don’t want to hardcode tool-tip labels we can help our self’s with tool-tip  used in ContentNavigationTree widget (“epi‑cms/component/ContentNavigationTree”). There is a “epi/i18n!epi/cms/nls/episerver.shared.header” resources file which contains all necessary texts.

Below is complete Javascript widget:

Backend code

We need to set new widget class on the backend side. To do this we could prepare a separated EditorDescriptor with new UIHint. But since we need to replace the ClientEditingClass property only, we will simply create new attribute class that implements IMetadataAware interface. In OnMetadataCreated method we will set widget class to “alloy.editors.extendedContentSelector”.

To proceed we have to use new attribute together with UIHint to describe model property. This will be the standard Content Selector UIHint like [UIHint(UIHint.Image)]. The ExtendedContentReferenceSelctorAttribute can be used with all other UIHints (Block, BlockFolder, MediaFile, MediaFolder).

New property  widget will display the tooltip with ID over the label:
ContentSelector - tooltip icon

..and after we double click on the label we will start edit selected content:

Content Selector property with preview

The complete source code is available on Gist.