Gravatar for pblrok@gmail.com

Question by pblrok, Nov 29, 2017 9:50 AM

Coveo Hive and a custom component

I have a few custom components that I implemented for 4.0 version. I want to implement something that is the same as a reusable configuration item that comes with 4.1 version. But I do not know what to do.

In version 4.0 to implement custom coveo component I inhereted my property template from Base Id Template and implemented a c# class that inherets BaseModel and sets values in a property through ParametersHelper and then I made a model item and a rendering item. In version 4.1 I suppose my template item shoud inheret Base UI Component and I shoud make c# class something like this (as in the example)

Can anyone help with it and describe what I shoud do step by step?

And I want to add custom property to Coveo Search Interface component and Facet component how can I do it?

1 Reply
Gravatar for flguillemette@coveo.com

Answer by François Lachance-Guillemette, Nov 29, 2017 1:22 PM

You have a great start there!

I have to be honest with you, the documentation is lacking about this for now. so let me recap some of the stuff you used and see if you figured it out right :)

`SitecoreProperty` is used to *Read Properties from Sitecore*. It has to match the template name in Sitecore.

`SearchUiProperty` is used to *Write Properties for the Coveo JavaScript Search Framework*.

`DefaultCaption` up there will output the value coming from the `DefaultCaption` template into the `data-default-caption` attribute.

I think that your big missing piece is the Model.

Here is a sample of what you need

public class FacetDropDownModel : BaseModelWithProperties<FacetDropDownProperties>
{
}

Inheriting this model provides some properties that you can use:

The `Properties` object which contains all the values read from the data source.

The `RawProperties` dictionary which contains key-value pairs for all the attributes required for the Coveo JavaScript Search Framework.

You must create a reference to this model in Sitecore, and use it in your custom rendering. You can pretty much copy-paste the `Coveo Facet` component and change some variables to match your custom model, and it should work.

Hope this helps! Don't hesitate if you have more questions, and documentation is on the way for this :)

Gravatar for pblrok@gmail.com

Comment by pblrok, Nov 30, 2017 10:28 AM

How can I add a preview animation for custom component like in facet as example?

Gravatar for pblrok@gmail.com

Comment by pblrok, Dec 4, 2017 8:37 AM

How can I read Rendering Parameters in properties class?

Meybe i shoud define property in properties class

[SearchUiProperty]
public string DefaultValue { get; set; }
<br>

and then set value in model (OnPropertiesInitialized override this)?

Ask a question