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.
This should be quite simple. You should just select a default view in the settings of the bucket (or bucket template’s standard values):
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’:
This does not work. The reason for this is at line 1050 of ItemBucket.js in \sitecore\shell\Applications\Buckets\Scripts\ :
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:
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.
[…] choosing names for your view – I’ve blogged about some of the problems with this already and how they can break the default […]
Hey Andy,
today I run into the same problem you described in this post. And I must say that it’s not fixed in Sitecore 8 (rev. 150427).
Reblogged this on Coresighted and commented:
Great post by Andy Burns.