Skip Navigation

[Resolved] Allowing users to choose how search results are displayed

This thread is resolved. Here is a description of the problem and solution.

Problem:
The user would like to allow visitors to display the results of the view, either as a list or as a grid.

Solution:
Currently, there is no built-in way to switch view design on Toolset Views or Toolset Blocks. But I believe this can be done either, by Javascript and CSS, or by using two different content templates and conditionally display one or the other based on a URL param that can come from a custom control.
- Javascript/CSS: You can build a Javascript function that will add a custom CSS class to the view ("grid" or "list"), and you can build custom CSS scoped to those CSS class to style the output differently.
- Different content template: If you are using legacy Views instead of blocks, you may use the wpv-search-term shortcode and conditional shortcodes to display a different content template for each design.

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-214940

This support ticket is created 4 years, 5 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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by michaelO-8 4 years, 5 months ago.

Assisted by: Jamal.

Author
Posts
#1686955
view with boxes.png
view with just text.PNG

Tell us what you are trying to do?

Hi, I was wondering if there was a simple way to allow a user to choose how results from a search are displayed. We use one view that displays cards for each toolset post (see image below) and most users like this. However, some users might want to display the results in search differently, such as plain text.

I was wondering if there was a simple way for users to be able to toggle the views that are displayed. For example, if the switch is on, display the results with a view as cards. If the switch is off, display the results with a different view as just text.

The toolset thread: https://toolset.com/forums/topic/multiple-views-updated-from-single-parametric-search/
seems to do something similar and display the results in multiple ways, but it would be great if users could have control over which view they would like to display.

Is there any documentation that you are following?
https://toolset.com/forums/topic/multiple-views-updated-from-single-parametric-search/
Is there a similar example that we can see?

What is the link to your site?

hidden link

#1687393

Hello and thank you for contacting the Toolset support.

Currently, there is no built-in way to switch view design on Toolset Views or Toolset Blocks. But I believe this can be done either, by Javascript and CSS, or by using two different content templates and conditionally display one or the other based on a URL param that can come from a custom control.
- Javascript/CSS: You can build a Javascript function that will add a custom CSS class to the view ("grid" or "list"), and you can build custom CSS scoped to those CSS class to style the output differently.
- Different content template: If you are using legacy Views instead of blocks, you may use the wpv-search-term shortcode and conditional shortcodes to display a different content template for each design.
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-214940

I can file this as a feature request to our developers, but that does not mean that it will be released. Our devs and product managers will evaluate it and decide, but we won't have an ETA for it. Let me know if you want this feature to be added to Toolset.

#1688891

Thank you for your help! Yes, if you can add this as a feature request that would be great. I will try some of the approaches you suggest and reach back out if I need further assistance.