Sitecore now provides us with this very useful ways of searching for items which are organized within item buckets.
We ran into a requirement where we didn’t want multiple tabs to open as and when one clicked on a search result, and we wanted the search result item to open in the main content tree instead.
This would enable the content authors to locate items in the item tree and create subitems / manipulate them. Even though the bucket search results page does allow creation of subitems (provided insert options are set), this provides a simpler means of browsing through subitems in a more effective manner.
To be able to achieve this, we need a config update and corresponding code update.
Code:
using Sitecore; using Sitecore.Buckets.Pipelines.UI.LaunchResultPipeline; using Sitecore.Data; using Sitecore.Data.Items; using System; namespace MySite.SitecoreProcessors { public class LaunchSitecoreResultMainWindow : LaunchSitecoreResult { protected override void LaunchResult(LaunchResultArgs args) { if (!string.IsNullOrEmpty(args.IndexableId)) { ID itemId = ID.Parse(args.IndexableId); Item myItem = Context.Database.GetItem(itemId); if (myItem != null) { Context.ClientPage.SendMessage(this, String.Concat( new object[] {"item:load(id=", myItem.ID, ",language=", myItem.Language, ",version=", myItem.Version, ")"})); } } } } }
Here’s the config update:
<sitecore> <processors> <uiLaunchResult> <processor desc="sitecore"> <patch:attribute name="type">MySite.SitecoreProcessors.LaunchSitecoreResultMainWindow, MySite</patch:attribute> </processor> </uiLaunchResult> </processors> </sitecore>
So now, when we search for an item within a bucket, and click on a search result, it will open in the main content editor.
Thanks! You saved my day!
LikeLike
I belive there should be ContentDatabase:
Item myItem = Context.ContentDatabase.GetItem(itemId);
If use context.Database it is core and error as a result
LikeLike
There is a settings for this: master:/sitecore/system/Settings/Buckets/Item Buckets Settings
http://blog.rauljimenez.co.uk/searching/
LikeLike