Skip Navigation

[Resolved] Travel Site

This support ticket is created 3 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.

Our next available supporter will start replying to tickets in about 1.80 hours from now. 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)

This topic contains 15 replies, has 2 voices.

Last updated by Christian Cox 3 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1713811

Hi, I am building a travel site and want to use the map to display the locations of all travel posts in the loop, to show pins of all places visited.

All worked fine to start with, but as I am adding more posts, the loading time increases massively, eventually leading to errors. It's a real pain, the page can take up to a minute to load. The sensible solution is to turn to pagination, so the page doesn't have to load all posts at once. However, then the map stops working as required:
1. The map only displays the location of the posts on the current page, not all posts
2. when moving to the next page with AJAX, the map just loses all locations and centres on Africa, 0, 0.

How can I set it up so I have pagination (ideally infinite scroll) but the map displays all post locations for all posts, even those which are not visible on the current page?

#1713853

Hello, you could try to solve this with two Views. Use one unpaginated View to insert markers on a map, and a View that displays paginated results outside the map but does not insert any map markers. If your paginated View uses front-end or Query Filters, those should be configured identically on both Views. Insert both Views on the same page or template to produce a paginated list of results with all unpaginated pins shown on the map simultaneously. The View that displays markers on the map should not display any front-end filters - if those are required, display them only for the View that shows paginated results.

Let me know if you have problems implementing this solution, and I'll try to give more targeted advice.

#1713873

Thanks!
I am currently using an WP Archive for this - I thought Views were retired? Can I still do this and keep the same setup to work as an archive, allowing me to display content when people click on a category?

#1714031
query-filter.png

Toolset Views the plugin is being phased out in favor of Toolset Blocks, but Views are a feature of the system that will not be going away. A View Block gives you the ability to build a list of posts of some kind. Unfortunately you cannot build a new View in the WordPress Archive editor with Toolset Blocks. You must build the View in another part of the site, like in an unassigned Content Template. Then you can drag a View block into the WP Archive design somewhere outside of the loop. Place the map block similarly outside the loop, and you can configure the marker setting to point to your View block as the address source.

You must add Query Filter(s) on the View to mimic any filters inherently or explicitly applied to the WP Archive. For example, if you are desiging an archive for the Category taxonomy, you must apply a Category taxonomy Query Filter in the View and configure it to respond to the current archive page taxonomy term. See query-filter.png for an example of this. Use the Block Navigation menu at the top of the screen to select the top-level View block, exposing the Query Filter panel. If your WP Archive includes any other Query Filters, you must add those in the View as well.

#1714711

That's confusing! But I think I got it. Thank you!

I tried doing what you describe. I think I got it almost right.

I created a Page which has two Views in it:
View 1. this is the one I actually want to see, paginated. Map in this view is set to Source: View Block: View 2
View 2. this only calls for post names, with all the content hidden in CSS

Both views have the same filters set up, and filtering works well, both on map and in content. The site is set up to use this page as the static home page.

However, now the archives are still a problem. I want taxonomies to display on each post in the loop in View 1, and be clickable. But clicking on taxonomy links takes me to the WP Archive. But the Archive doesn't allow me to add View 2 to it. I can duplicate the content of View 1, but then I'm back to the initial problem: in archives, I either have pagination on and the map doesn't display all the pins; or I have pagination off and the page loads for ages and in some cases comes up with an error

I tried adding another view to the WP Archive, but it tells me I can't have nested views. I tried to add View 2 to a Content Template and add the Content Template to the WP Archive, but this just doesn't display at all.

How can I do it, so that the trick that works for the main blog page and for filtering, also works in Archives?

#1715157
Screen Shot 2020-07-22 at 1.42.04 PM.png

I tried adding another view to the WP Archive, but it tells me I can't have nested views.
But the Archive doesn't allow me to add View 2 to it.
You can't build a new View in a WP Archive, but you can place an existing View in the Archive Output section. I'm attaching a screenshot here, maybe you're trying to insert it somewhere else? Content Template doesn't seem to work, you are correct, the template simply shows blank like you described. But you can drag or place a View block in the Archive Output (not the loop) section and select an existing View created elsewhere on the site.

#1715379
Capture0.PNG

Unfortunately, this just isn't what I'm getting. When I try to add a view in the Archive Output through the Add Other Blocks option, I just get an error saying Nested views creation is not supported at the moment. See pic.

#1716197

May I log in and take a quick look? Which archive are you editing?

#1716593

I'm sorry, I'm not able to log in with this password. Can you double check the credentials? Perhaps it wasn't saved after you generated a new password? I will activate private fields again in case you need to share new credentials.

#1719761

Okay I was able to add "hidden view" in the WP Archive here: hidden link
Something strange is going on up above the filters, where the block editor is having trouble with the "collapser" elements. I left that as-is for now, and placed the View using a View block inside the WordPress Archive Output Area block. I didn't experience any error messages or problems inserting the View, so I'm not sure what you were experiencing. The screenshot you shared looks like a capture of the loop area - you can't add the View in the loop. Only in the archive output area.

I configured the View block to show only the results, since filters aren't needed here. Also you won't be able to edit this View from the context of the archive editor page, just to be clear. You must edit it elsewhere...wherever it was created, probably.

#1719819

Thank you for looking into this!

But I don't think it works:
- The archive pages display with two maps
- The Archive doesn't have pagination
- When I turn pagination on, it does the same thing it did before - the (second) map only displays the locations associated with the posts on the first page, then when I change the page, it all breaks.

To test this, go to the site and click on, say 'Europe' on any post. Compare the results from the two maps, and scroll down to see what happens to the map when the next page loads.

#1720123
archive-marker.png

- The archive pages display with two maps
Sure, there are two map blocks so two maps are displayed. It looks like there is a map block in "hidden view", and another map block in the WordPress Archive Output Area. There should only be one map on this page, so I'm not sure why there is a map in both the WordPress Archive and in the View. I must have implied that somehow, sorry! One of these should be removed. I'm not sure what you're trying to do with hidden view on the homepage exactly, but it seems hidden view has the map block that should be deleted. I'll let you decide. For now, I have updated map #2 in the WordPress Archive Output area to point to the hidden view as the source for its markers, since this is the source containing all the unpaginated results, correct? Now both map blocks show all unpaginated markers, I believe. I made that change for you (see the archive-marker.png screenshot to note where I adjusted this) so hopefully the map block in hidden view can be removed now.

If the map block in hidden view is used elsewhere and you need to keep it there, you should duplicate hidden view and remove the map from the duplicate version. Select that map-free View here in the archive instead so the map is not displayed, and leave the current hidden view with the map undisturbed for other placements. I think this is a good idea anyway, because hidden view now contains the designed results in the loop, hidden with CSS. I assume because you want to use this somewhere else on the site? That is not really the most performant approach from the server-side perspective or from the client side perspective. A separate View with nothing in the loop will load faster, it will be lighter in page weight, and it may also have benefits for SEO and accessibility.

- When I turn pagination on, it does the same thing it did before - the (second) map only displays the locations associated with the posts on the first page, then when I change the page, it all breaks.
I think this was because the marker source configurations were set incorrectly, as I mentioned. I changed them to point to the hidden view as the source of the markers. Remove the map from hidden view and you should be able to use pagination again in the WordPress Archive.

#1720543

Thanks again. I'm not sure I get it all, but the fact is that the page still doesn't do what it is meant to do.

After your last change, now I have two maps (and yes, I'll hide one of them), but now in the archive they both display all of the markers for *all posts ever*, not from *all posts in the selected category*.

I want the map in a paginated archive to display ALL and ONLY the locations for the posts in a selected category (even if some of the posts are not showing on the first page).

The current solution means the map displays ALL the locations for all posts whether they are in the category or not, which is not what I want.

The previous solution meant the map displayed ONLY the locations of the posts on the first page of the paginated archive, which I also do not want.

I mean, it works with the homepage view and filters just fine - just have a look.
1. Go to the main page and in the top filters select 'Europe'
2. Click on 'Europe' on any of the posts

Those two should obviously look the same. But 1 is a page with a view and filters which works a dream, while 2 is an archive and it's a mess.

#1720995

Thanks again. I'm not sure I get it all, but the fact is that the page still doesn't do what it is meant to do.
The current solution means the map displays ALL the locations for all posts whether they are in the category or not, which is not what I want.
Thanks for your patience while we work through this, I'm not really familiar with the site's contents and it was not immediately obvious to me the markers in the archive were not filtered correctly. In Toolset terminology, the View providing the source for the archive map markers (currently "hidden view") is not filtered correctly. You need to add a Query Filter to the View that provides the source for the map markers (currently "hidden view"). I explained this earlier and included a screenshot, but it was not yet implemented by either of us: https://toolset.com/forums/topic/travel-site/#post-1714031.

I believe you were trying to use "hidden view" on the homepage, and we got sidetracked trying to implement "hidden view" in this archive as well. At this point, using the same View in both places is really no longer an option. You must create a new View that can be used on the archive, separate from the View shown on the homepage. In this new View, you will add a taxonomy Query Filter, and set that Query Filter to respond to the current archive term (see the link above). In the archive, you will edit the View block and choose the new View instead of "hidden view". In the archive map block, you will update the marker source settings to point to the new View instead of "hidden view".

Would you like to create the new View, insert it in the archive, and link it up to provide the source for the archive map markers? Or would you prefer I do it for you?

#1722987

Yes! This worked, thank you so much!

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