WPML Integration for Algolia
-
Hi,
I’m currently following the guide here which is referenced on this post here that mentions updating both my copies of
instantsearch.js
andautocomplete.js
which I’m doing, although the code doesn’t seem to match.For example on
instantsearch.js
I’m told to update this block of code:/* Instantiate instantsearch.js */
var search = instantsearch({
appId: algolia.application_id,
apiKey: algolia.search_api_key,
indexName: algolia.indices.searchable_posts.name,
urlSync: {
mapping: {'q': 's'},
trackedParameters: ['query']
},
searchParameters: {
facetingAfterDistinct: true,
highlightPreTag: '__ais-highlight__',
highlightPostTag: '__/ais-highlight__',
filters: 'wpml.locale:"' + current_locale + '"', // This is the line we added.
}
});Yet that block is different in my version, which is below:
/* Instantiate instantsearch.js */ var search = instantsearch({ indexName: algolia.indices.searchable_posts.name, searchClient: algoliasearch( algolia.application_id, algolia.search_api_key ), routing: { router: instantsearch.routers.history({ writeDelay: 1000 }), stateMapping: { stateToRoute( indexUiState ) { return { s: indexUiState[ algolia.indices.searchable_posts.name ].query, page: indexUiState[ algolia.indices.searchable_posts.name ].page } }, routeToState( routeState ) { const indexUiState = {}; indexUiState[ algolia.indices.searchable_posts.name ] = { query: routeState.s, page: routeState.page }; return indexUiState; } } } });
Is this a case of the files being updated since the guide? I’m struggling to see which is the latest, correct guide to reference.
Many thanks,
Viewing 15 replies - 1 through 15 (of 15 total)
Viewing 15 replies - 1 through 15 (of 15 total)
- You must be logged in to reply to this topic.