0

Context: I am using the sxa search box component in site A to search through the items of site B, which is a shared site. The search itself it is working fine: when I click enter, it shows the results page of site B, as required. Also the search box drop-down is showing the right suggestions.

Issue: when clicking on a suggestion in the drop-down I get a 404, since the link of the suggestion does not contain the domain of the site B and the item is not found on site A.

Question: it is possible to add the domain to the link of the suggestion in order to manage this multisite scenario or is there another way of doing this?

I have tried to set the field Suggestions mode to Show search results as predictions but the required behaviour is to link directly to the item when clicking on the suggestion, not to go to the results page.

Thanks for any advise

1 Answer 1

1

You can create a custom rendering variant for Search box to get rendered html for suggestions. By default it uses horizontal, you can create a new for example horizontal-absoluteurl.

Custom Rendering Variant For Search Box with Absolute Url - Sitecore SXA Rendered Html via Rendering Variant Image: How you can check what html is rendered for the item via your rendering variant

Scriban have parameter to get url {{i_item.url }} see if that works, if not you will need to create custom scriban extension like {{i_item.url_absolute}}.

The custom scriban extension which will have your c# logic for getting absolute url for item by detecting its related site context (by matching path or any other logic you want).

You can refer this blog creating scriban extension: https://www.dotnet-ltd.com/blog/create-item-extension-with-scriban

<div class="field-title your-custom-rv-for-absolute-url"><a title="{{i_item.Title}}" href="{{i_item.url_absolute}}">{{ sc_field i_item "__Display Name" }}</a></div>

Note: I'm sharing the idea, but it hasn't been tested yet.

Hope this helpful!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.