Skip Navigation

[Resolved] Adding Show on Map button

This support ticket is created 2 years, 8 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 17 replies, has 3 voices.

Last updated by nadavL 2 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#2154657

Hi,

I have a page to search/filter posts from specific type: hidden link

I wish to add a button called "Show On Map". Clicking this button will open a popup or a new tab displaying the filtered results on a map. I know I can add a map on the page view, but I don't want this. I want it to open in a separate window.

Could you please advise on the best way to achieve this?

Thanks

#2154803

You'll probably need some custom JavaScript here to achieve exactly what you're looking for. Assuming your View updates URL parameters now, you could create a duplicate View and place it on a separate Page. In the duplicate View, you can remove the text listings from the results and replace them with map markers and display a map on the same page. To navigate from the original View to the new map View, you can place a custom link that copies the URL parameters from the current page URL and applies them to the URL of the page containing the map View.

Javascript to copy current page URL parameters would look something like this example:
https://www.sitepoint.com/get-url-parameters-with-javascript/

Be sure to set target="_blank" in the custom link to force the link top open in a new window.

#2156757

I started working according to your suggestion but before trying to popup the map, I tried a simpler option of displaying the map in the same page.
I've created a new page and duplicated the view.
As you can see in the screenshot video, I don't see the locations on the map. When I select "View block" in the map source, I get an error.

Video link: hidden link

Please advise what I'm doing wrong before I continue, trying to do it in a popup.

Thanks

#2157337
Screenshot 2021-09-01 185502.jpg

Updating my previous reply:
I just updated Toolset to the latest version and it resolved the problem I had when selecting "view block".
Please see the new page, currently have the text results + map at the bottom of the page: hidden link

It works ok now on the same page. Please find the attached image with the settings I've used. How do I direct it to another page and not the current page (where the map and the view are both displayed)?

#2157593

How do I direct it to another page and not the current page (where the map and the view are both displayed)?
Okay thanks for the update. If I understand correctly, you have two custom search Views now:
/trip-planner (the original))
/trip-planner-map (clone of the original, includes a map)
Your plan is for the User to select some search criteria in /trip-planner, and the search results will update there in /trip-planner. You also want to display a link of some kind that says "show results on map" or something similar. That link will redirect the User to /trip-planner-map in a new window with their previously selected search criteria, so that the same filtered results appear on the map.

If I am correct so far, you'll need to update the Views so that the filters trigger corresponding URL updates. This setting is managed in the View editor screen in Custom Search Settings > Let me choose individual settings manually. The option you need is "Update URLs after loading search results." Then as your Users select custom field filters and/or taxonomy filters, you should begin seeing URL updates like:
https://yoursite.com/trip-planner/?wpv-fields=123&wpv-taxonomy=slug

Using custom JavaScript, you would copy the full query string, i.e. ?wpv-fields=123&wpv-taxonomy=slug , and apply that same query string to a simple HTML text link to the /trip-planner-map page, i.e.:

<a href="<em><u>hidden link</u></em>">Show results on map</a>
#2158439

Thank you, you got exactly what I meant.
I was unable to find the setting you wrote: View editor screen in Custom Search Settings > Let me choose individual settings manually

Please explain where exactly this is.

Thanks

#2158485

I was unable to find the setting you wrote: View editor screen in Custom Search Settings > Let me choose individual settings manually
This setting at the per View level is only available in the legacy Views editor. If you are using the legacy View editor, you may need to activate the Custom Search Settings panel if it is not already visible in the View editor screen. To activate this panel, scroll to the top right corner of the screen and click the "Screen Options" tab. You can activate the Custom Search Settings panel here.

At a more global level, you can manage URL history for custom search in Toolset > Settings > Front-end Content > Browser history management for AJAX custom searches.

#2158533
Screenshot 2021-09-02 182725.jpg

Please see attached image. This is what I see in the View option. The custom search part doesn't have 'Let me choose individual settings manually'

#2158801

Yes, your screenshot shows a View block in the Block editor, not a legacy View in the legacy View editor. The "let me choose..." setting only exists in the legacy View editor. If you're using the Block editor to design the View, please go to Toolset > Settings > Front-end Content and find the "Browser history management for AJAX custom searches" section. Check the checkbox to "Enable history management settings for AJAX custom search". If not already active, that option should enable on-the-fly URL updates in AJAX Views with custom search filters.

Then test the View again on the front-end of the site, and as you manipulate the custom search filters you should see the URL update to reflect the chosen filter options.

Is that working, or is there a problem with browser history URL parameters?

#2159675

ok, in that case, we're good. The settings are already set as you described and the URL changes according to the filters.
I'm afraid I wasn't able to get this to work. I thought I'll be able to manage with some JS but I'm not a developer and can't implement what you suggested on the link.

If you can help with that this would be great. If it's too much, I'll understand.
If you need admin access I'll be happy to provide one.

Thanks

#2161367

I don't have a cut-and-paste solution available for you, as this is pretty custom. Toolset provides the ability to show custom search results in the same page or in a separate page, but does not provide built-in features for achieving both things in the same custom search View. I can try to work on something in my free time but since it's custom coding this is a fairly low priority.

#2161693

I completely understand that a custom solution is a low priority and if you'll find the time that would be great.

You wrote: "Toolset provides the ability to show custom search results in the same page or in a separate page".
What is the solution? Showing custom search results on a separate page is exactly what I need.

Thanks

#2162411

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Nadav,

Christian is currently out today on holiday and should be back tomorrow to continue assisting.

Thanks,
Shane

#2163601

Hi,

Thank for the update.
Happy holidays.

#2163927

Showing custom search results on a separate page is exactly what I need.
Okay sure, that is fairly simple to achieve since it is a built-in feature. To be clear, this means that the search form will appear on one page and must include a submit button. The User will select their filter options and click the submit button, then they will be redirected to a second page where the search form will appear again along with the filtered results - in your case, the results will be displayed on a map. We have details about this process available here: https://toolset.com/course-lesson/displaying-search-results-on-a-different-page/

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.