Content Providers 101 – Part III: Finishing Touches
The provider is now almost complete, we just need to put the finishing touches to it.
Searching: In the component, there is a search box. In order to get it to return actual items, a search provider is needed
To connect the search provider to the attendee component, override and match the SearchArea property on the repository descriptor (AttendeeRepositoryDescriptor) to the Area property in the search provider:
The search provider will work for both the component and for the global navigation search
Speaking of search, if you are using EPiServer Find, the attendee data will automatically be indexed to Find when when running the content indexing job. This happens as Find will traverse the entire content tree and index all the IContent there is, including the “attendees” content folder beneath the root node.
This means that you can get attendees as a part of UnifiedSearch with just a single line of code:
Preview: EPiServer offers a great on-page editing experience, so we should enable this for attendee content as well.
The preview controller in Alloy only works with BlockData, but can easily modified to work with attendees as well:
What I’ve done is to remove the IRenderTemplate<BlockData> interface, and instead specified the model type in the TemplateDescriptor. Since TemplateDescriptors allows multiple attributes, I’ve added one for attendees as well.
Change context: When double-clicking blocks or media in the assets pane, the clicked item will be loaded and displayed. In order to get the same behavior for our attendees, we need to specify this in the AttendeeRepositoryDescriptor:
The HierarchialList component will look for a matching property. If it does not exists or is set to false, the context will not change when double clicking the item, and you will have to use the edit button from the drop down menu in order to load and see the item.
Custom icon: In the assets pane, the icon that is being used for attendees is the standard content icon. In order to get one step closer to UX nirvana, a more descriptive icon should be used instead. This is done by creating a UIDescriptor:
Tip: See lists of icons and corresponding css class names at ux.episerver.com
Want to try it out? Get the source code here
Also: A big thanks to Linus Ekström for being super helpful!