Customized Sitecore Search View – List Buckets Values in Dynamic Placeholders

Many of you know this problem: We have a bucket containing items and we want to visualize the items in a list with all values and not only the standard properties like:

  • Template
  • Location
  • Version
  • Created
  • By
  • Language

The magic words to do this, is „Dynamic Placeholder“!

2017-11-02_14-43-54

What we have

1. Template „Order Programme Form“

2017-11-02_11-34-07

The field „Bucketable“ of the standard values of the template must be set to „true“.

2. Bucket containing items of template „Order Program Form“

With the following Settings:

2017-11-02_11-41-55

  • „Is Bucket“ to „true“
  • „Persistant bucket filter“ is the preset filter, which can’t be changed in the Sitecore search.
    You can separate the with a semicolon and the „+“ means a logical AND.
    I recommend: Set the location to the folder itself, otherwise it finds the items outside the folder too.
    And filter on the template „Order Programme Form“, otherwise other item types or folders could be found also.
  • „Enabled views“ is set to the view which we will create later in the next step. It should be set to this view as default.

Here is how the Persistant bucket filter look like:

2017-11-02_14-43-40

What we have to do

1. Configuration File

  • root = ID of the folder containing the buckets
  • template = ID of the „Order Programme Form“ template
  • maps = every field of „the Order Programme Form“ template
  • fieldId = ID of the matching field in the template
  • dynamicViewName = must match the name of the DynamicPlaceholder in the view we want to create later

2. Custom Bucket View

We create our own View:

2017-11-02_13-55-09

Under Settings/Buckets/Views we make a new View called „Order Programme View“.
We can build the table view with plain HTML and thus control how the table should look like in the following three sections:

  • Header
  • Item
  • Footer

Here are the three samples of the HTML code:

  • Placeholders are SystemPlaceholders (for other available SystemPlaceholders take a look in the standard table view)
  • DynamicPlaceholders are the placeholders from the configuration file

3. Custom Bucket Facet (Optional)

We wanna filter our search also on the field „Lang“

2017-11-02_13-59-06

Under System/Settings/Buckets/Facets we create our own Facet: „Lang“

2017-11-02_14-43-54

When completing a search, there is now a new facet called „Lang“.

4. C# Code

Model for the „maps“ in OrderProgramme.config

 

In OrderProgramme.config we also declare a pipeline for „buckets.dynamicFields“:  
The source code for the configured pipeline:

Please keep in mind to change to code where we get the configuration item to your own implementation.

Voilà!

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

*

*

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>