0

I'm using Weighted Search on a site and want to prevent the results from listing entries from certain sections.

Looking at the README.md suggests that this functionality has not been built into the plugin. However, does anyone have any experience of getting the plugin to only search in certain sections? Either through the {% set results %} OR tweaking the plugin?

I've tried added .section('mysection') to the {% set results %} but this seems to break the search.

// Working

{% set query = craft.request.getParam('q') %}
{% set results = craft.weightedSearch.substringSearch(query) %}

// Not working

{% set query = craft.request.getParam('q') %}
{% set results = craft.weightedSearch.substringSearch(query).section('mysection') %}

Hoping someone else has managed this and I don't have to go back to the standard Craft search.

Thanks

2 Answers 2

1

I've also seen this issue myself when using weightedsearch and as a result I have jsut gone and created a solution for this by adding a new parameter to the substringSearch function.

I've also commented on the issue which was raised back in January on the weightedsearch github page and added my updated files as a zip file, so please feel free to download it and give it a go if you wish. By putting it onto the issue tracker they will hopefully pull this feature into the plugin in a future release now.

You can see further details here: https://github.com/wja-no/craft-weighted-search/issues/1

0

Without having used the plugin - have you tried something like:

{% set params = { section: 'mysection' } %}
1
  • Thanks Nutmeg. Unfortunately there was a fair amount of changes which needed to be made to the plugin, which you can see from Matt's answer - who has also kindly submitted the code updates to the plugin developer, so hopefully these will get integrated into the plugin in the near future. Thank you. Dec 7, 2016 at 11:10

Your Answer

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

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