• Hello! I faced with the following issue.
    I added params to data-additional_search_params . Like this return $args['filter_by']='category:category-1 and it works. But when I click any other filter on the front-end all this filter_by states are lost. So I see all possible posts for other taxonomies. I need to make filter_by always work for any other request.

    I really enjoy your plugin! Thank you for your work

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author CodeManas

    (@codemanas)

    Hello @sbdev1stepan ,

    After you have added the additonal_search_params, in the first load, the results are based on that filter, in your case by category:category-1. But once you apply another filter on the front end, a new search request is sent that will reset your previous request for the filter by category:category-1.

    For this to be not reset, you can do it using the swtInstance like this:

    swtInstance.cm_swt_instant_search_1.helper.addDisjunctiveFacetRefinement('category', 'category-1').search();

    This will apply the filter category-1 as checked and when you apply an additional filter that won’t affect your previous filter of category-1.

    Hope this is helpful.

    Regards,

    Codemanas

    Thread Starter sbdev1stepan

    (@sbdev1stepan)

    Thank you for the response!

    The code you provided does the same as swtInstance.renderState[postType].refinementList[taxSlug].refine(term);
    So they are added to CurrentRefinements. And

    1. Is there a way to imitate the exact behaviour of data-additional_search_params?
    2. I need to do it on each Filter click. I found just swtInstance.on('render', setPresetTerms); Event. Maybe there is better Event for this purpose?
    3. Can you please share Docs for this plugin JS or Git if it is public? Because your site doesn’t containt detailed info and Instant search JS ( site ) is not all present in the plugin script. Or the only way is to ask you?))
    Plugin Author CodeManas

    (@codemanas)

    Hello @sbdev1stepan,

    Do you want to show only one category pre-assigned and not show other categories in the filter? Can you please clarify your use case in detail?
    If possible, can you share some screenshots/video and your site link please?

    Thread Starter sbdev1stepan

    (@sbdev1stepan)

    Here your are the link.

    I have several taxonomies. I need to make some Terms to be mutable some immutable. Due to your help I managed to achieve this the following way :

    1. I store the mutable/immutable terms in data-attributes in .cmswt-InstantSearch.

    2. add params :

    1. for the first render I add mutable Terms swtInstance.on(‘render’, setMutableTerms). Mutalbe means the user can close it.
    2. on each search click I add immutable params swtInstance.on(‘render’, setImmutableTerms) . Immutable means the user can’t close it. And also hide HTML for .cmswt-Filter and .ais-CurrentRefinements-item.

    3. After adding mutable/immutable params call swtInstance.helper.search();

    On the example page ( link ) you can find both mutable and immutable Taxonomy terms.

    But it in my opinion it is not the best way to do it.

    (1) The filters are still there though invisible and there are several searches

    (2) The search function is called several times on each click

    Can you please help me with the above question?

    • This reply was modified 1 year, 1 month ago by sbdev1stepan.
    Thread Starter sbdev1stepan

    (@sbdev1stepan)

    ( 3 ) When you change post type all changes are lost and don’t work again. Can you help with it eigther?

    Plugin Author CodeManas

    (@codemanas)

    Hello @sbdev1stepan ,

    Did the setting of setMutableTerms and setImmutableTerms work? I checked the site and I can close/uncheck the mutable terms in the site.

    The search function sends a new request on each click since it needs to pass the query to the search. But once it’s clicked, it’s cached. And yes, on each click, there’s request with the query.

    Regarding changing the post type, yes the changes are lost since, on the click of each post type, we are building a new search instance that has it’s own filter and facets.

    Thread Starter sbdev1stepan

    (@sbdev1stepan)

    Hello @codemanas ! Thank you for the answer)

    Yes setMutableTerms?and?setImmutableTerms?work. There are 2 filters set :
    1. mutable – Article-topics: Residential. Yes it can be closed
    2. immutable – Article-types: tierra-grande . It is hidden form user.

    The issues I would like to improve :
    1. I have to add immutable terms on each render Event.
    swtInstance.helper.addDisjunctiveFacetRefinement(taxSlug, term);
    Maybe there is a way to add that params to the request.

    2. I can change filter request on render Event only. I have to call the following function several times in order to set my mutable/immutable terms
    swtInstance.helper.search()
    Maybe there is a better way to do it

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Additional Search Params’ is closed to new replies.