Translate

Monday, January 11, 2016

Thumbnail search view customization

Although there is very detailed explanation on customizing search view in developer's guide; it provides example only to create thumbnail search view on basis of asset's attribute of type blob for docked thumbnail search view and undocked thumbnail search view. But what if you want to show blob attribute from asset's associated attribute? Thus, this post.

I have taken avisports site as an example. In avisports site, Article definition has attribute: relatedImage which is of type - AVIImage (subtype: ArticleImage) and thus, this assettype: AVIArticle qualifies for this customization. So overall, AVIImages's attribute: imageFile should be visible as thumbnail in docked and undocked search view on searching AVIArticle in Contributor UI.

Steps to follow:
1. Create a custom element: CustomGlobalThumbnailHtml under "CustomElements > avisports > AVIArticle > UI  > Layout > Search > View" as jsp
2. Copy the code from GlobalThumnailHtml.jsp from the element present under "UI  > Layout > Search > View" and paste in CustomGlobalThumbnailHtml file. This code is responsible for thumbnail view for AVIArticle as mentioned in ThumbnailViewConfig element under CustomElements.
3. Update CustomGlobalThumnailHtml and include following code after you get the type param, to fetch imageFile attribute and set it as url param and save it. This code will basically fetch AVIImage's imageFile attribute and set as url param.
4. Update ThumnailViewConfig element and DockedThumnailViewConfig element present under "CustomElements > avisports > AVIArticle > UI  > Layout > Search > View" to point to CustomGlobalThumbnail element.
5. Save and search any AVIArticle in your avisports, now thumbnails should be visible in thumbnail's view from imageFile attribute of asset - AVIImage.

Thus, in any project, thumbnail can be shown from associated asset's blob attribute in thumbnail search views (Docked and Undocked) with this simple customization.

To simply test it, I directly updated GlobalThumbnailHtml element which is not recommended.

AVIArticle Undocked Thumbnail View




AVIArticle Docked Thumbnail View

                                               ----------------------------------------------------
SUGGESTIONS/COMMENTS ARE INVITED
----------------------------------------------------