Gravatar for

Question by mcallahan, May 21, 2015 9:24 AM

Urls on multi-site sitecore solution

The urls in Coveo for the second site are not working correctly.

These are the sites…

<site name="demo" inherits="sitebase" hostName="site1.local" targetHostName="site1.local" contentStartItem="/sitecore/content/sites/demo/home" rootPath="/sitecore/content/sites/demo"/>

<site name="site2" inherits="sitebase" hostName="site2.local" targetHostName="site2.local" contentStartItem="/sitecore/content/sites/site2/home" rootPath="/sitecore/content/sites/site2""/>

The urls in the coveo search page in the first site work correctly.

  • site1.local/home

The urls in the coveo search page in the second site dont form correctly.

  • site1.local/sites/site2/home

The <ServerUrl> element in the Coveo.SearchProvider.config is set to site1.local. I think that is why the urls for all the sites resolve to that.

How can I make the urls resolve to their own sites?

Shouldn't this pipeline do this already?

  <processor type="Coveo.SearchProvider.Processors.ResolveItemSiteProcessor, Coveo.SearchProviderBase" />
1 Reply
Gravatar for

Answer by Sébastien Belzile, May 21, 2015 10:10 AM


support for URIs in multisite solutions has been improved and will be available in the July 2015 release.

For now, the best way to resolve URIs on your search pages is to add a processor in the coveoProcessParsedRestResponse pipeline, declared in the Coveo.SearchProvider.Rest.config file.

Simply call Sitecore's LinkManager to resolve the uri correctly. Use the GetItemUri(Item, UrlOptions) method.

In the arguments of this pipeline, you already have the current Sitecontext, which can give you the current database (you need this to retrieve the Sitecore item).

Gravatar for

Comment by mcallahan, May 21, 2015 1:04 PM

Assigning the url to the ClickUri doesn't have any effect.

This code does get hit, and the ClickUrl is assigned a value, but it doesn't show up on the Search page.

if (global::Sitecore.Data.ID.TryParse(idFromUri, out id))
    Item sitecoreItem = global::Sitecore.Context.Database.GetItem(id);
    if (sitecoreItem != null)
        result["ClickUri"] = global::Sitecore.Links.LinkManager.GetItemUrl(sitecoreItem);
Gravatar for

Comment by Sébastien Belzile, May 21, 2015 1:19 PM

  1. Try the property result.ClickUri instead of result["ClickUri"]. There is a difference between "clickUri" and "ClickUri", the latter is deprecated.

  2. This code does get hit, but the clickUri doesn't show up: How many results are you returning? We recently fixed a bug when re-serializing to JSON, that occurred when to many results were returning.

Gravatar for

Comment by Jean-François L'Heureux, May 21, 2015 1:21 PM

The dictionary key for the click URI is clickURI with a lowercase c. You should assign the property instead of modifying the dictionary anyway.

Can you try with result.ClickUri = global::Sitecore.Links.LinkManager.GetItemUrl(sitecoreItem); ?

Also, do you use the default result template in your search page or you modified it? The ClickUri is the one on the href attribute of the result title. The one displayed in the result fields table is the "PrintableUri". If you want this one to be changed too, you should also alter it in the processor.

Gravatar for

Comment by mcallahan, May 21, 2015 1:35 PM

That worked, awesome thanks!

Ask a question