Experience Sitecore ! | All posts tagged 'StackOverflow'

Experience Sitecore !

More than 200 articles about the best DXP by Martin Miles

Understanding Buckets: adding new items to buckets correctly

I just came across a question on StackOverflow about Buckets, so I decided to highlight in my blog, as it it is based on very common misunderstanding of Buckets and their functioning principles. Here's the link to original SO question.

If briefly, a guy asked why having a bucket folder with several items in it, when he tries to add a new item, the one appears in a folder as normal item, not hidden. So every time he adds new item he has to perform Sync on that. So let's go and reproduce the situation by steps.

Prerequisites: I have a folder with some items that I am turning into a bucket (at that stage we assume those Articles 1 - 5 have Bucketable checkbox being set on individual level; if you don't know how to update a checkbox for multiple already existing items - here is the great blog post about mass update field values I wrote about):


At this stage my folder is a bucket, items are not displayed, but are searchable, everything functions as normal.



The issue: Then I try to add a new item called Article 6 into my bucket folder. That item is being created as normal, is diaplyed within a folder, and there is also a notification panel warning about storing unbucketable item within a bucket folder. I believe - that is an issue of person asking a question on StackOverflow (see image below). That new item has normal path as an immediate child of bucket folder (not date-specific as defaults for bucket items path) and looking into Item Buckets sections reveals that Bucketable checkbox is not set. To add this Article 6 item into bucket, one needs to check its Bucketable field and then perform Sync from the Ribbon above.


But why that behavior happens?


Solution: Well, this checkbox isn't set but should be on items creation. How do we get that behavior? Just checking that checkbox in corresponding template's Standard Values. Screenshot below shows Article template that is a data template for all Article items. Standard Values for template are always called as __Standard Values so fields set in that item (with static values or tokens) will be auto pre-set each time and item of that template is being created:



So, as soon we have updated Standard Values with Bucketable checked, we try to create another article (of the same template, for sure), we logically call it Article 7. Once created, Article 7 is already bucketable by its Standard Values and is immediately stored in the bucket. There's no need to perform Sync! It also preloads content area right hand side (or you may search for it from Search tab) and if you pay attention to an Item path field - it is being located exactly as specified in (default in our example) bucketing configuration:



Hope this post helps you to understand a concept that is hidden behind the buckets!

Tip: copying Presentation Details manually

I came across a question on StackOverflow where a guy asked about copying presentation details and decided to share this quick tip. Saying Presentation Details I mean all the information about layouts, renderings, placeholders etc., so whatever you usually configure on that screen:



So, you usual data is stored within item's fields, but where does presentation live? Well, presentation is also kept within item, but in a slightly different location.

You page template is inherited from Standard Template, it has plenty of important fields and sections, among which there is Layout section. Let's go and see what is there. But before, open View tab ensure Standard fields is checked in order to display all sections provided by Standard Template and also check Raw values option to display actual content of the fields:


Then, scroll down to Layouts section and expand it.


Rendering field contains all presentation details, serialized into XML. So now, if you copy them 'as-is' to clipboard and insert to another item - that item will immediately same layout, all renderings in the same order, placeholders etc. You may also copy that across environments, assuming both target and source environment have those layout and renderings.


Note: if you need to copy Presentation Details just within same database, there a nice and quick solution right from the UI:


Hope this helps!