Problems setting a default Bucket search view in Sitecore

I’ve been doing a bit of customisation to a Sitecore 7.5 instance that is going to have to store a lot of nodes in one particular area. Naturally, thought of using buckets, which would be ideal. I’ve a few things to cover in this, but I’m going to start at the end – and the hardest problem.

I wanted to set a default search to run when someone comes to the bucket in the content editor.

Capture

This should be quite simple. You should just select a default view in the settings of the bucket (or bucket template’s standard values):

Capture2

In this example, my custom search view is ‘Transfers’. You can create one of these by creating an item in /sitecore/system/Settings/Buckets/Views/ There are articles about this sort of thing (Keith Ball’s is a particularly useful one).

Unfortunately, setting the default view didn’t seem to work. You could go to the bucket, enter a term, click search – and nothing would happen. If you then clicked on the ‘view’ buttons to the right things would spring into life – but the default fails. I figured out why.

The View item has a Name, and a Display Name. For example, here the item has a name ‘Transfers’ and a display name ‘Transfers View’:

Capture3

This does not work. The reason for this is at line 1050 of ItemBucket.js in \sitecore\shell\Applications\Buckets\Scripts\ :

Capture4

CurrentView comes through as the item name – ‘Transfer‘. Yet the line below uses a jQuery selector – on a CSS class for some inexplicable reason – looking for that CurrentView. However, the HTML does not use the item name, but rather the Display Name:

Capture5

So… if the two are different, your default search can’t find the .click() event to call, and your search fails.

Right, well, why don’t I make both of them “Transfer View“? Well, notice that the display name comes through with spaces removed. CurrentView does not – it comes through as ‘Transfer View‘. Thus line 1051 fails to find the .click() method – and the thing fails again.

So, rules of thumb:

  • Don’t use different names for Item Name and Display Name on Bucket Views.
  • Don’t use spaces in Bucket View names.

If you do that, the default view works nicely. Though I’m still baffled by why use a jQuery select for the CSS class!

This may already be fixed in Sitecore 8, but hopefully it’ll give someone else an easy fix.

Advertisement
Problems setting a default Bucket search view in Sitecore

3 thoughts on “Problems setting a default Bucket search view in Sitecore

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.