Introducing Site Search Custom Bric

have you inspected the page with dev tools to see if the server is throwing any errors?

The web server threws a 404 as for testing purpose before pushing live update of the website, tests were done on the server but on a different path (/testing)… thus trying to retrieve /js/site-search-data.json led to the above error code :wink:

Thanks for helping! :+1:

I just purchased the search brics, and everything looks good in the blocs preview when i press the play button - and the browser preview looks good. however, when i load this onto my test linux server, it produces no results. that server is running centos 7.3 and no results pop up. a quick review shows these errors:

TypeError: undefined is not an object (evaluating ‘searchData.length’)
filterResults — site-search.js:17
(anonymous function) — site-search.js:4:294

Please note the export created two .js files called site-search, the second one is named site-search-1.js
and this is there. I shelled in, and looked at the file via vi editor, its there. I see it. but
Is not loading in the browser. is cache busting not compatible with this javascript?

Any Help would be greatly appreciated! :grinning:

Check your project attachments in project settings you may have a duplicate site search resource there.

The server sounds like it can’t find the data file, make sure that resides on the server in the correct location (check export structure and mirror on server).

Hi @Norm, perhaps I’m getting ahead of myself here, but I was curious if this Bric will also integrate with the WordPress implementation? Since the default search in WP is a bit rubbish…

Im afraid not, it’s a static search tool, so it wont work with a database powered Wordpress site.

However, you can easily integrate the wordpress search into Wordpress themes built with the next major version of Blocs.

1 Like

SOLVED: the issue is that line 6 of the site-search.js file needed this minor change, preceding decimal so it looks one folder higher. it should match the location of the js that loads it if they are in the same folder.

from: dataPath=’/js/site-search-data.json?’+Math.random();
to: dataPath=’./js/site-search-data.json?’+Math.random();

…and extending this one step further, the same step taken on line 47. adding the preceding . in the href for the matching items. now its working 100 percent on my test site.

1 Like