Skip Navigation

[Resolved] Update view results with ajax on archive page when filter form is in widget

This support ticket is created 6 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 3 replies, has 2 voices.

Last updated by Beda 6 years, 3 months ago.

Assisted by: Beda.

Author
Posts
#924465

I am trying to:
1. Build an archive for a custom taxonomy
2. Have a custom search on this archive
3. Update AJAX results when visitors change any filter values
4. Place the filter form in a widget (sidebar)

Link to a page where the issue can be seen:
hidden link

I expected to see:
Updated search results after selecting a filter.

Instead, I got:
No filtering when I check a term in the filter options.

The steps I took are as follows.

1. Create a custom taxonomy (taxonomy-1)
2. Create an archive view for this taxonomy
3. Add the standard wordpress category as a (checkboxes) filter to the view-filter

[wpv-filter-start hide="true"]
[wpv-filter-controls]
<div class="form-group">
<label>[wpml-string context="wpv-views"]Taxonomies 1[/wpml-string]</label>
[wpv-control-post-taxonomy taxonomy="taxonomy-1" type="checkboxes" url_param="wpv-taxonomy-1"]
</div>
<div class="form-group">
<label>[wpml-string context="wpv-views"]Categories[/wpml-string]</label>
[wpv-control-post-taxonomy taxonomy="category" type="checkboxes" url_param="wpv-category"]
</div>
[/wpv-filter-controls]
[wpv-filter-end]

4. Set the "Custom Search Settings" to: "AJAX results update when visitors change any filter values"
5. Place the filter form in a widget

The ajax filter works fine as long as I don't separate the view-filter and the view-output.
When I place the view-filter in a widget/sidebar the ajax filtering does not get triggered.

Hope you can help.

Cheers,

Tako

#924633

It is not possible to update a View without submit button in a Widget.

Moreover it is not possible to add a Archive View as a Widget to your site, this is only possible for Post Views with Custom Searches without AJAX submit.

If you use the only Tool to add Views to Widgets, the 2 Widgets we provide, then you will see that the View's Filter Widget states:

There are no Views with a custom search. You can add them (here).

Remember that only Views forms containing a Submit button can be used on a widget

If you use a View with Submit Button, you need to target a page to show the results.
AJAX will not work with this.

It will always target a results page and hence, reload.

In this scenario, AJAX cannot work.

If you require "split" Views you can try this on the same page, within a Toolset Content Template or a simple page or a Layout with the views Cells.

But, not on widgets.

#948982

Hi Beda,

Thanks for the reply.

I forgot to mention that we only show the widget on the archive page(s). So the "target" page would always be the current page/archive where the visitor is when filtering. The main reason we want to use the widget is because the theme we use (avada) has a built in sticky option for widgets. So then the filter will always be visible.

The funny thing is that when I click on the terms themselves (instead of the select boxes) the Ajax filtering gets triggered. So I imagine it would be possible to trigger the filtering with the select boxes?

I probably could use JavaScript to trigger a click event on the terms when selecting a checkbox but I am not sure how I would reset the filtering when deselecting a checkbox.

If you have any further ideas about this that would be nice.
But if it can't be done we will look for another solution.

Cheers,

Tako

#949034

Widgets don't belong to the post object, and even if, the Widgets cannot be used to create an AJAX updated View, as they require a results page which even if the same page/archive, will be reloaded and not updated by AJAX.

- You need a search button in the View to even use it in the Widget
- You need to load/pass the results page.

I can add a feature request to allow this, but for not, what you want is possible only if you present the results and search on the same page.
Not on the same Template (where Widgets are part of, but as well post content, title, etc) but on the same page (which translates to the same content).

So, you an for example create a Toolset Layout and split the view.
Or, you can add the split view to a native Page or Post.

But, you can not use the AJAX features on a Widget.