Hierarchical menu from inner pages relative links

HierarchicalMenu links works fine from the home page. All menu links (Eg. http://localhost/?q=&hPP=10&idx=drafts&p=0&hFR[hierarchicalCategories.lvl0][0]=Agriculture%20and%20Farming&is_v=1 is relative to home page or http://localhost/). Result item link is clicked and now it is the corresponding detail page Eg. http://localhost/lfogjh-fgoknfglgkfnd-gvldfknv-dkjb-edited-seminars-workshops-493846835

The hierachicalMenu now displays the menu and count correctly on the result detail page too. However, when the menu link is now relative to the current url ( Eg: http://localhost/lfogjh-fgoknfglgkfnd-gvldfknv-dkjb-edited-seminars-workshops-493846835?q=&idx=drafts&p=0&hFR[hierarchicalCategories.lvl0][0]=Agriculture%20and%20Farming%20>%20Seminars%20Workshops&is_v=1 )and not the homepage or localhost, and so clicking on it doesn’t give the corresponding results page.

Could not find anything related with this neither in the documentation or in other related forums. Any help will be appreciated.

I’m not sure I understand. Do you have an implementation of instantsearch on http://localhost/lfogjh-fgoknfglgkfnd-gvldfknv-dkjb-edited-seminars-workshops-493846835 ? If instantsearch is not loaded on this page, the page can’t load the results.

I have an implementation of instant search on the home page. A searchBox widget is present and the left navigation panel has a hierarchicalMenu with two levels which aggregates the total number of results and links pointing to the respective aggregated results. Also present are the hits widget which renders the results and a pagination widget. On this page, the instantsearch works as expected.

Now, I’m trying to get the hierarchicalMenu on the left navigation panel of an inner page as well. There is no searchBox in this page. When that page is visited, the left panel should give the hierarchicalMenu with links pointing to the aggregated results. I have added the same instantsearch code on this page, except the searchBox, hits and pagination widgets and the hits-container part. Now the left panel has the HierarchicalMenu with the aggregated results.
However the problem is with the links, the results are pointing to. The links now point relative to the present page, instead of the home page. i.e. If http://example.com is the home page, the aggregated results links are like http://example.com/q?=some+query+string which works fine. But from an inner page http://example.com/inner, the hierarchicalMenu links from this page points to http://example.com/inner?q=some+query+string which obviously doesn’t give any results.

Presently, I have removed the hierarchicalMenu from the inner pages left navigation panel, and placed a static menu of top level category pages only with static links (eg. http://example.com/q?=query+for+top_level_category1). I would be thankful for any suggestions.

Yes, I have an implementation on instantsearch on inner pages as well (say example.com/inner-page) with hierarchicalMenu as the only widget here. The menu aggregates the results correctly. However the menu inks are now relative to the current page - example.com/inner-page?q=queryString - instead of example.com/q?=queryString and the former doesn’t give any results.

I understand, I need to use the transformData parameter of hierarchicalMenu widget to transform the url of the menu links, so that it is now relative to the root domain instead of the current url. But I do not know how to go about it.:worried:

Tried some combinations like below. My knowledge is pretty limited here.

transformData: { item: ['url' => function(url) { return url.replace(window.location.pathname,''); }], }

Hi,

Sorry for the late answer. I don’t think you will be able to fix what you’re doing with the urlSync. However we have a new way to synchronize the search in InstantSearch.js v2 called router. You can check the guide here: https://community.algolia.com/instantsearch.js/v2/guides/routing.html