Skip Navigation

[Gelöst] Maps distance filter using a custom field as the location

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

Get the distance value from related "EOI" post(current-client-address field) and related "site" posts(site-address field).

Solution:

You can follow our document to customize the [toolset-maps-distance-value] shortcode, for example:

https://toolset.com/forums/topic/maps-distance-filter-using-a-custom-field-as-the-location/#post-2070691

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#toolset-maps-distance-value

This support ticket is created vor 1 Jahr, 8 Monate. 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
- 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/Hong_Kong (GMT+08:00)

This topic contains 8 Antworten, has 2 Stimmen.

Last updated by stuart vor 1 Jahr, 8 Monate.

Assigned support staff: Luo Yang.

Author
Artikel
#2066125

I am trying to use the following shortcode to get the distance from a location that is stored on the parent (this is the primary, or location I wish to measure from).

I am then within a view loop on the child post looking at the child location value post-meta custom field.
Like this below - I have also tried it with a short-code, but this didnt work.

[toolset-maps-distance-value location="current-client-address' item='@eoi-map.parent'" postmeta='wpcf-site-address']

What could I be doing wrong here?

Thanks

#2066169

Luo Yang
Supporter

Languages: Englisch (English ) Vereinfachtes Chinesisch (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hello,

Please check our document:
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#toolset-maps-distance-value
The shortcode [toolset-maps-distance-value] does not support item attribute

In your case, you can create a content template, for example "parent-eoi-info", in the content display the shortcode without item attribute:
[toolset-maps-distance-value location="current-client-address' postmeta='wpcf-site-address']

In view's loop, display above content template shortcode with item attribute, for example:
[wpv-post-body view_template="parent-eoi-info" item="@eoi-map.parent"]

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-153372

#2066315

Unfortunately that didn't work... this is what I tried to test the combinations... you may need a duplicator backup (its local).

Content Template: parent-eoi-info

map:[toolset-maps-distance-value location='current-client-address' postmeta='wpcf-site-address'] END.
<br>Dev Site address: [types field='site-address'][/types] END.
<br>Client Address[types field='current-client-address'][/types] END.

VIEW - in-between markers

<br>
with item:@eoi-map.parent -
<br>
[wpv-post-body view_template="parent-eoi-info" item="@eoi-map.parent"]
<br>
with item:@eoi-site-connect.parent -
<br>
[wpv-post-body view_template="parent-eoi-info" item="@eoi-site-connect.parent"]
<br>
without item -
<br>
[wpv-post-body view_template="parent-eoi-info"]

RESULTS on front end:

with item:@eoi-map.parent -

with item:@eoi-site-connect.parent -
map: END.
Dev Site address: END.
Client AddressOatlands Crescent, Oatlands NSW, Australia END.
without item -
map: END.
Dev Site address: 10 Eastern Creek Drive, Eastern Creek NSW, Australia END.
Client Address END.

New threads created by Jamal and linked to this one are listed below:

https://toolset.com/de/forums/topic/displaying-a-view-of-related-posts-of-a-related-post/

#2067087

Luo Yang
Supporter

Languages: Englisch (English ) Vereinfachtes Chinesisch (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Please provide the duplicator package, you can put the package files in your own google drive disk, share the link only, also point out the problem page URL and view URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#2069633

Luo Yang
Supporter

Languages: Englisch (English ) Vereinfachtes Chinesisch (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Thanks for the details, I am downloading the files, will update here if find anything

#2069761

Luo Yang
Supporter

Languages: Englisch (English ) Vereinfachtes Chinesisch (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Your website settings are very complicated, the problem page URL you mentioned above is a single "Map" post.

Are you going to compare get the distance value from related "EOI" post(current-client-address field) and related "site" posts(site-address field)?

Please confirm it first, thanks

#2070025

That is correct.

The 'Map' page is going to contain the view that displays the data from parent EOI (address of the head office), the 'sites' are proposed locations the business may like to move too.

Therefore I would like to compare the businesses current location (EOI Current Client Address, on the EOI CPT) to all of the 'Sites' ( Site Address'es) on the 'Map' page.

There may be a better way of organising this but this is what I came up with 🙂

The 'Map' page will be shared with each client so they can decide based on the distance from their current office to their new proposed offices.

Thanks Luo

#2070691

Luo Yang
Supporter

Languages: Englisch (English ) Vereinfachtes Chinesisch (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Thanks for the confirmation, please try these:
1) Create a post view "child-site-posts":
- Query "Sites" posts
- Filter by post relationship or repeatable fields group owner:
Select posts in a EOIs Sites relationship that are a related to the current post in the loop.
- In views loop, display the distance shortcode like this:

[toolset-maps-distance-value location='[types field="current-client-address" item="@eoi-site-connect.parent"][/types]' postmeta='wpcf-site-address']

Here you can display more information of "Sites" posts

2) Edit the content template "parent-eoi-info"
hidden link
Display above view's shortcode, like this:

[wpv-view name="child-site-posts"]

3) Edit the content template "Template for Maps":
hidden link
Add a shortcode block, display above content template shortcode, like this:

[wpv-post-body view_template="parent-eoi-info" item="@eoi-map.parent"]

Then test the single "Maps" post in frontend, it works fine in my localhost.

#2070777

My issue is resolved now. Thank you!

This worked a treat, I could also use: [toolset-maps-distance-value location='[types field="current-client-address" item="@eoi-site-connect.parent"][/types]' postmeta='wpcf-site-address']

on the initial view between the Markers to get the distance on the popup perfectly.

Thanks again!