Skip Navigation

[Resolved] Hiding ‘private’ events from a map but still show in View results

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

Problem: I have a View that shows Events as a list, and also on a map. If the Event is "private", I do not want to show it on the map but I want it to appear in the results.

Solution: Use a checkbox field or a radio field to set the public / private status of each item. Use conditional HTML to show or not show the map marker for each result.

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
https://toolset.com/documentation/user-guides/display-on-google-maps/

This support ticket is created 5 years, 9 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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)

Author
Posts
#1196746

Hi

I am trying to resolve a requirement for a client and just wondering if you had any suggestion.

We have a directory of events. Users add events via fron end forms, we have various taxonomies like genre and once published They display in either a post archive or a separate view which displays the various events in a lst, we can filter at the top by genre or event type

And the location field of each event is displayed a s map marker at the top of the page. The archive currently just show those events in that paginated list (as is the same view) so it will show the locations of event 1-10 then 11-20 an so forth

We have a serate view which shows all events on the map on a different page.

We have a new requirement. Some of the events are happening in places that are either private or not open to the public so whilst we wanty their event to be listed we do not want to show their location on the map. However we capture the location as part of the event listings as we need the information.

So the logical thing to me seems to have a check box when adding an event - ie "is this a private event yes or no"

The events listing itself is easy and I assume I just conditionally hide the location map on the single event page for those events marked as private.

However I want a map view - which i assume is a custom search which

1) Displays all events that are NOT marked private
2)The user can filter the map by say genre or county
3)And geo locate so search within 10km of the user location

In my 'content selection' on my view I have the opportunity to select 'events' and then appy front end filters .
But just not sure how I can in effect have a content selection of 'events minus private events- and then apply the front end filter.

Does this make sense or am I thinking about this the wrong way?

I was thinking about work around which may work - ie
- could I parse a value or a class to the map marker for any private event and then 'display:none' or something like that (not very smooth)
- could I parse and alternative location for all private events' for example we could create a mythical location called 'Private' and then show all private events on the map in this one place - such as in the sea of something

Any ideas would be appreciated

#1196901
radio.png
checkbox.png

Hi, I think your checkbox idea makes sense but there is a technical limitation. It's not easy to search for items without a checked checkbox. It's easier to search for items with a checked checkbox. So you should switch the checkbox to mean "public" instead of "private", i.e. "is this a public event yes or no". Another option is to use a radio field with two options: 1 for public and 2 for private (see radio.png)

Either way, there's nothing wrong with adding some front-end filter controls and combining those with pre-defined Query Filters for other fields. The filters will work together. When you edit the View, make sure the Query Filter editor panel and the Search and Pagination editor panel are both visible. If you cannot see them, scroll up to find the Screen Options tab. You can activate both panels here.

To add front-end filters, you would use the "New Filter" button in the Search and Pagination editor panel. But to add predefined filters, you should add them directly in the Query Filter area. Filter by the checkbox field (or radio field if you decide to switch). Configure the filter to filter by field value is a string equal to constant 1 (see checkbox.png). Radio field configurations will be the same.

#1199972

Hi Christian
Sorry for my later response I must have missed the notification.

Thanks for all your help and the thought process help me resolve the issue which ultimately was a lot simpler - by using full custom display mode i can combined pre defined with user defined filters.

My next problem is this - but not sure if if needs to be another ticket.

Recognising whether an event is public or private is now probbile and working.
And to conform the private 'element ' is just location so 'private' events will still appear in search results - the map on the single event template conditionally display s- ie if private then do not show.

I can create a map of all public events that are filterable on a different page and that works

The final problem is the archive - I have a paginated archive (25 items) - which a map at the top which displays a location pin for each of the 25 events within that pagination.

If i filter the archive then I am removing the provate events - whereas I only want them removed from the map on these page.

I could create a separate view that sat at the top of the archive with a map of all public events- but ideally i would like this view to just show markers for the public events currently displayed in the paginated results - but the results themselves to show both public and private events.

Perhaps a better term d hidden rather than private . Basically we want them listed you just cannot attend them and do not wish to publicise their location - they may be schools and the like

Many Thanks

#1199974

You can use conditional HTML in the archive loop to show or not show a marker for each post result. Wrap your marker shortcode in a wpv-conditional statement that tests whether or not the event is public. We have documentation for conditional HTML available here: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

Let me know if you have questions about that.

#1200142

My issue is resolved now. Thank you!