Skip Navigation

[Resolved] display custom post when clik on map marker on the same page

This support ticket is created 4 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 12 replies, has 3 voices.

Last updated by kayser 4 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#1630395
Apic3.jpg
Apic2.png

Hi
in hidden link
If i click on popup content to map marker i go to this page (Apic2.png)
hidden link

But I want the custom post to appear next to the card as in Apic3.jpg
How should I do?
Thank you
Guyk

#1630983

Hello, if I understand correctly you would like to change the behavior of the map marker. When the marker is clicked, you would like to open the marker popup (this is called an InfoWindow in Google Maps) and also load the main post content in the area where the View currently appears. I think this is a great idea, but unfortunately there is nothing exactly like this built-in to the Views and Blocks plugins and it would require some complex custom code. You and I have discussed a similar request in the past: https://toolset.com/forums/topic/custom-post-content-near-of-the-map/ Unfortunately it is still not possible to control content outside the map based on click events inside the map.

This level of customization falls outside the scope of support I can offer here in the forums. If you are a JavaScript, HTML and CSS developer, I can show you some examples that might help you implement something similar to your requirements. If you are not a developer, then the following alternative requires less custom code but is still quite complex and will be challenging to implement.

As an alternative, you could change the template for DLS posts so that it looks more like the template for the de-loire-en-seine page. Remove the "J’Y PENSE" sidebar (or place the sidebar content below the post content instead) and add the map on the left side instead. I can help you add some custom code that will automatically open the popup of the current post when the page loads. Nigel created some custom code in another ticket, and I can help you implement this code with a few minor changes: https://toolset.com/de/forums/topic/maps-open-popup-on-start-load/

So the new flow would be:
- User goes to hidden link
- User clicks a map marker
- Popup appears containing link to post
- User clicks link to post
- User is redirected to the DLS post. The new DLS post template looks much like the de-loire-en-seine page. The map appears on the left side and the post content appears on the right side.
- The Map Marker popup for the current post is automatically opened

Let me know how you would like to proceed.

#1631739

Hello
I'm halfway through. When I click on the markers popup on the first map, everything is good.
hidden link

But in the second map on the markers popup I have the same content everywhere.
hidden link

your help would be welcome also with "open the popup of the current post"

Guyk

#1632403

It depends on how the markers are added to the map. Are the markers inserted in a classic View, or in a View created in the Blocks editor? If it's a classic View, can you share the contents of your Loop and any Loop templates used in the View? If it's created in Blocks, can you share some screenshots of the Marker configurations from the Block Editor?

#1632659
pic2.png
pic1.png

here they are
hidden link
pic1
hidden link
pic2 is a content template

and in the two popups I have the same content
hidden link">le dernier bateau
Laurette Jean-Marie
<h4>
Christian Cox

field-or-view.png
popup.png
remove.png

Okay I assume you have created this marker using the Map block in the Block editor. If that is the case, I see the problem and I can replicate it on my own test site. Any shortcode you place in the popup content editor will save correctly once, but then it will be replaced with the rendered content and display the contents from the same post no matter which marker you click. In other words, if you place this code in the popup content editor panel of the Map block in a View created in a Content Template assigned to some CPT:

[wpv-post-title]

...then save the template, on the front-end of the site the post title will be displayed correctly for all markers. This will work correctly for all posts and all markers until you edit and resave the template in wp-admin. Then you will see that the shortcode has been replaced with the title of the preview post, for example:

la rigueur du commerce, la joie du déversoire

Now if you resave the template, this hard-coded post title is saved in the template instead of the shortcode. I will escalate this to my 2nd tier support team for some additional investigation. Until the problem is resolved by our developers, you should turn off the marker created by the Map block and recreate the marker with a shortcode. You can do this by editing the View in the block editor and adding a Fields and Text block inside the View's loop block. Edit the Fields and Text block and you can use the "Add a Field or View" button (see my field-or-view.png screenshot here for an example) to insert a Marker shortcode. In the "Marker data" tab, you can insert your popup contents using shortcodes and HTML as needed (see popup.png). I can't tell exactly what your shortcodes should be based on the images I have seen so far, but I imagine the post title with link will be included in an h4 tag, for example:

<h4>[wpv-post-link]</h4>

Now that the marker is included with a shortcode, use the "Remove this marker" link in the Map block to remove the broken marker attached to the Map block (see the remove.png screenshot here for an example). Let me know if this is too confusing, I'll be glad to login to your wp-admin area and make the required changes. I have activated private reply fields here so you share login credentials securely, if necessary.

#1637855

Shane
Supporter

Languages: English (English )

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

Hi Kayser,

Christian is currently unavailable today but he will be back tomorrow to continue this thread with you.

Thanks,
Shane

#1638475
Screen Shot 2020-05-26 at 9.25.09 AM.png
Screen Shot 2020-05-26 at 9.25.02 AM.png

Hi, I'm afraid I misunderstood the problem, can you help? You said:
But in the second map on the markers popup I have the same content everywhere.
hidden link;

Can you clarify this for me? When I click the markers on this map, I see different content in each marker popup. See the screenshots here for examples. I thought I saw a problem in wp-admin where the content for all popups was repeated, but a coworker pointed out that the text in the popup editor is highlighted in yellow, indicating a shortcode which will be replaced dynamically. On the front-end I cannot see a problem.

#1638585
Annotation 2020-05-26 154428.png

Hello
hidden link
in all the popup i get the same "le dernier bateau"
Here is a problem

#1640497

I see now, the problem is not apparent until I log out of the site. Please stand by, I am still working on this and I will give you another update shortly.

#1640523

I purged the WP Rocket cache and it seems to be working better now. Can you check it?

#1640907

I disabled wp rocket and I still have the same problem.

#1645893

My issue is resolved now. Thank you!