Gravatar for pblrok@gmail.com

Question by pblrok, Nov 22, 2017 12:57 PM

CoveoDynamicPlaceholder does not work

I use coveo for sitecore 4.1 and have started creating a hive search page, I was doing it step by step like in the documentation, but after I added seatch interface I found out that the placeholder `@Html.Sitecore().CoveoDynamicPlaceholder("coveo-ui-content", @Model.Id)` does not work. I mean I can not insert any renderings ("add here" button is not displayed and placeholder area is not shown). When I change placeholder to default `@Html.Sitecore().Placeholder` everything works. Log file does not have any errors.

Other renderings with Coveo Dynamic Placeholder does not work too.

Can anyone help with this issue?

3 Replies
Gravatar for flguillemette@coveo.com

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

We stumbled upon this issue internally.

It looks like the key we are using in our custom Dynamic Placeholder can trigger some existing Dynamic Placeholder, but generates an invalid key that does not match any placeholder.

To fix this, we reordered the `Coveo.UI.Components.ExperienceEditor.Processors.GetDynamicKeyAllowedRenderings` processor from the `Coveo.UI.Components.ExperienceEditor.config` file to be executed _before_ the Dynamic Placeholder module.

Putting it first will ensure that the Coveo Dynamic Placeholder are handled by the Coveo processor. Since our custom implementation is more restrictive, it should not mess with keys created with another module.

We have yet to figure out if there is a permanent fix for this.

As a side note:

Changing to `@Html.Sitecore().Placeholder()` will not work in the long run since it generates the same placeholder when using multiple `Coveo Result List` components, or multiple sections.

Gravatar for pblrok@gmail.com

Comment by pblrok, Nov 22, 2017 2:29 PM

Is it correct? Coveo.UI.Components.ExperienceEditor.Processors.GetDynamicKeyAllowedRenderings execute before the Dynamic Placeholder module but Coveo Dynamic Placeholder does not work.

Gravatar for pblrok@gmail.com

Comment by pblrok, Nov 22, 2017 2:35 PM

Maybe the best solution to use DynamicPlaceholders instead of CoveoDynamicPlaceholders?

Gravatar for flguillemette@coveo.com

Comment by François Lachance-Guillemette, Nov 22, 2017 2:37 PM

Here are some details about this:

Coveo uses the following format for its dynamic keys:

`[placeholder]_dynamic_[identifier]`

Where `[placeholder]` is the effective key to use, and `[identifier]` can be any string.

But most existing implementations need the following format:

`[placeholder]_[uniqueId]`

Where `[placeholder]` is the effective key to use, and `[uniqueId]` is any GUID.

When the first placeholder resolver picks a Coveo Dynamic key, it resolves it to `aplaceholder_dynamic` instead of simply `aplaceholder`.

Gravatar for pblrok@gmail.com

Comment by pblrok, Nov 23, 2017 1:54 PM

@Html.Sitecore().Placeholders do not work after @Html.Sitecore().DynamicPlaceholders. I mean that you solution works only for @Html.Sitecore().CoveoDynamicPlaceholders. I insert a frame randering that has @Html.Sitecore().Placeholders and it does not work again. In my project all placeholders are dynamic. I think the best way is to dublicate coveo hive renderings and placegolders then to replace all placeholders in this renderings to @Html.Sitecore().DynamicPlaceholder.

Gravatar for pblrok@gmail.com

Comment by pblrok, Nov 23, 2017 1:58 PM

Does Coveo Hive work fine with sitecore 9 (DynamicPlaceholders)?

Gravatar for flguillemette@coveo.com

Answer by François Lachance-Guillemette, Nov 22, 2017 3:51 PM

I have investigated further on this issue by installing the same package as you.

I thought the issue was coming from the `GetDynamicKeyAllowedRenderings`, but it is caused by the default `GetPlaceholderChromeData` that is *replaced* by a custom one.

The Coveo processor receives a key that is already parsed by the custom processor, so Coveo cannot properly extract the key.

I have tried putting it in a `patch:after` like two other Dynamic Placeholder modules do, but the original module calls base.Process which Sitecore do not like at all.

For now, I have a workaround to propose:

Since the dynamic key is generated using the ID of the model, you can modify the DOM Unique Id property on all your components to hard, string values instead of IDs. This will generate a key that looks like `[placeholder]_dynamic_YOURID`, since it will be a string, it will no longer be parsed by the custom processor.

Gravatar for flguillemette@coveo.com

Comment by François Lachance-Guillemette, Nov 22, 2017 4:52 PM

I have written a simple Powershell Extensions script to help you replace IDs:

function Replace-KeyInPlaceholders($originalId, $newId) { $item = Get-Item ".\"; $item | Get-Rendering | % { Set-Rendering -Instance $_ -Item $item -PlaceHolder $_.Placeholder.Replace($originalId, $newId) } }

Considering that you already have Powershell Extensions installed, and that this is a page created using the "Example Search Page" branch:

  1. Select your Example Search Page created from your branch
  2. Select the Data Source for the Search Interface. It should be located under "Example" > "Example Search Interfaces" > "Search Interface".
  3. Take note of its ID (like _C606340E-DC5C-48D2-B627-A91A5CD50287)
  4. Change its ID to something that is not a GUID, like ExampleSearch
  5. Right-click on the Example Search Page (the one with the Renderings that you would edit in the Page Editor).
  6. Click on Console
  7. Copy-paste the script above to register it in the local session
  8. Execute the command Replace-KeyInPlaceholders "YOUR_GUID" "THE_NEW_GUID" (like Replace-KeyInPlaceholders "_C606340E-DC5C-48D2-B627-A91A5CD50287" "ExampleSearch")

This will go through the renderings and replace the GUID in all the placeholders.

Gravatar for pblrok@gmail.com

Comment by pblrok, Nov 23, 2017 1:46 PM

@Html.Sitecore().Placeholders do not work after @Html.Sitecore().DynamicPlaceholders. I mean that you solution works only for @Html.Sitecore().CoveoDynamicPlaceholders. I insert a frame randering that has @Html.Sitecore().Placeholders and it does not work again. In my project all placeholders are dynamic. I think the best way is to dublicate coveo hive renderings and placegolders then to replace all placeholders on this renderings to @Html.Sitecore().DynamicPlaceholder.

Gravatar for flguillemette@coveo.com

Comment by François Lachance-Guillemette, Nov 23, 2017 3:13 PM

I noticed that it still does not work, even with my workaround since some calls to `CoveoDynamicPlaceholder` don't use the second parameter, thus fallback to the rendering unique ID.

I could craft a fix for this, but it would require you to go through the Coveo support channel.

Gravatar for pblrok@gmail.com

Answer by pblrok, Dec 14, 2017 8:02 AM

I use Coveo for Sitecore 82 4.1.184.18 and last version of dynamic placeholders.

As I see in change log for 82 4.1.184.18 version

SC-2459Resolved conflict between dynamic placeholder module and Coveo Hive dynamic placeholder.SC-2461Resolved conflict between dynamic placeholders for renderings without Model.Id.

So I made a test:

All have parent dynamic placeholder name, but contain renderings for parent and for the placeholder that should be (I mean for example that the first placeholder should have the name coveo-ui-header-section but has col-huge and has renderings from col-huge placeholder and coveo-ui-header-section placeholder). If I add some coveo renderings with placeholders all placeholder names are correct and work fine.

How can I fix it?

Gravatar for flguillemette@coveo.com

Comment by François Lachance-Guillemette, Dec 14, 2017 12:57 PM

Did you also read the warning at the top of the Release Notes page?

To fix the issue, you have to execute the steps here: https://developers.coveo.com/display/SitecoreV4/Solving+the+Conflict+Between+Keys+from+Dynamic+Placeholder+Modules+and+Coveo+Dynamic+Placeholders

I know it is annoying, but we changed the key format to no longer have any conflict. Once you migrate, your DynamicPlaceholder module should work as usual.

Gravatar for flguillemette@coveo.com

Comment by François Lachance-Guillemette, Dec 14, 2017 1:09 PM

What I did in this version is change the placeholder key format, you can see that in your Search Interface component's ID: `coveoC606340E`.

For the placeholder, I don't get why they would be `col-huge` since there should no longer be any key conflict... Let me check it out.

Could it be this issue? https://github.com/Fortis-Collection/dynamic-placeholders/issues/3

Gravatar for flguillemette@coveo.com

Comment by François Lachance-Guillemette, Dec 14, 2017 1:36 PM

Looks like this is caused by the Fortis Dynamic placeholder module itself:

https://github.com/Fortis-Collection/dynamic-placeholders/blob/master/Source/DynamicPlaceholders/Pipelines/GetPlaceholderRenderings/GetDynamicKeyAllowedRenderings.cs

If you take a look at the regex, it is matching _whatever placeholder key that contains a dynamic key in its path_.

https://www.debuggex.com/r/PZY0v23SCFVEzNGS

Does your rendering also gets deleted on save?

It looks like the `item:saved` event is killing everything inside any Dynamic Placeholder:

https://github.com/Fortis-Collection/dynamic-placeholders/blob/master/Source/DynamicPlaceholders/Events/DynamicPlaceholder.cs

Ask a question