Skip Navigation

[Resolved] Split: Map should only show if the search produces results in the archive

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: Asia/Karachi (GMT+05:00)

Author
Posts
#2669245

I'm so sorry but I have another issue.
On the Properties Archive, the map should only show if the search produces results. How do I hide the map if there are no results?
I tried adding a conditional but do not see any options related to the field I am querying (Address).

#2669333

Hi,

Based on the setup of your archive, here are the steps, I'll recommend:

1. In the 'Grid Cell' block that contains the map block, you can include a custom class name 'map-container.

2. And in the same archive's CSS editor, include the following CSS code to hide this cell, by default:


.map-container {
visibility:hidden;
}

3. Lastly, in the CSS editor of the view 'List Vacancies in a Property (brief)', you can include the following CSS code:


.map-container {
visibility:visible !important;
}

As a result, this last CSS part that makes the map visible will only be loaded on the page through the view, if there is at least one result coming from the archive. Otherwise, the map will stay hidden.

regards,
Waqar

#2669427

Surely there is a better way to do this?
Isn't there "No Items Found Text" that can be shown in the map area if there are no results?
Or fallback coordinates to show a map area without any markers?

If I must proceed with your CSS solution, I will. But as currently written it will not work for me. The reason is that markers should be shown on the map even if the "List Vacancies in a Property (brief)" view has no results. The markers on the map should show if there are one or more Properties (CPT) results (as this is the Properties Archive). Vacancies is a different post type altogether and whether that view shows results is irrelevant here. (We are showing properties regardless of whether or not they have vacancy.)

#2669571

Thanks for writing back.

The custom CSS code that we include through a view is loaded, regardless, of whether it actually returns results or not. So my recommended solution would still work, if the view 'List Vacancies in a Property (brief)', brings no results.
( in this case loading of the view matters and not its results )

You can simplify this further though.

Instead of following steps 2 & 3 from my last reply, look for the 'WordPress Archive Loop' block in the archive and open its 'Loop Template' settings tab.
( screenshot: hidden link )

Any content that we add in this 'No Items Found Text' field, is loaded only when the archive returns no results.

You can add your customized message and the CSS code to hide the map cell, in this field:


[wpml-string context="wpv-views"]No properties found[/wpml-string]

<style>
.map-container {
visibility:hidden;
}
</style>

#2670771

That worked and seems like a better solution. Thank you.