I hope there is a better and smarter way to achieve this functionality. But..
There are few points to consider:
- How to determine if the view should be Thumbnail
When you load Folder content, it does not necessarily mean that you load folder itself. As you mentioned you have a MM schema associated. But unless UI loaded a folder it knows nothing about this folder associations.
As a list solution, you can put an extra/extension information in List root element such as list parent id or its managed action.
<tcm:ListItems ID="tcm:1-1-2" Managed="10682" />
I'd advice to put this new attribute into your extension xml namespace.
<tcm:ListItems ID="tcm:1-1-2" Managed="10682" uibc:isThumbnailView="true" xmlns:uibc="http://tridion.uibeardcore.com/BeardcoreListExtensions" />
When you done with data extender. You should extend CME.
Probably the simplest way is to attach “load”
event listener on dashboard List. When list loaded, you can check its content and extract an attribute from root element.
if ($display)
{
(function ()
{
$evt.addEventHandler($display, "start", Extension$FolderThumbnailsView$_onDisplayStart);
function Extension$FolderThumbnailsView$_onDisplayStart()
{
$evt.removeEventHandler($display, "start", Extension$FolderThumbnailsView$_onDisplayStart);
var view = $display.getView();
if (view && Tridion.OO.implementsInterface(view, "Tridion.Cme.Views.DashboardBase"))
{
// Either (to avoid accessing private properties)
var filteredDashboardList = $controls.getControl($("#FilteredDashboardList"), "Tridion.Controls.FilteredList");
var list = filteredDashboardList && filteredDashboardList.getList();
// OR
//var list = view.properties.controls.list;
if (list)
{
$evt.addEventHandler(list, "draw", Extension$FolderThumbnailsView$_switchView);
}
}
};
function Extension$FolderThumbnailsView$_switchView(event)
{
var list = event && event.source;
if (list && !$evt.isUnloading())
{
var isThumbnailView = $xml.getInnerText(list.getContent(), "/tcm:*/@uibc:isThumbnailView", "false", { "uibc": "http://tridion.uibeardcore.com/BeardcoreListExtensions" });
if (isThumbnailView == "true")
{
list.setView(Tridion.Controls.List.ViewType.THUMBNAILS);
}
}
};
})();
}