Skip Navigation

[Resolved] Use data of related post types in marker_field and image link

This support ticket is created 4 years, 11 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 4 replies, has 2 voices.

Last updated by annemariev 4 years, 11 months ago.

Assisted by: Nigel.

Author
Posts
#1523933

Hi,

I am trying to make a view in which information of three many-many related post types are combined: Activities, Locations and Multimedia.

The Activity view enables you to search on activity features and shows a map with:
- activity markers (relationship activity-location)
- activity images (relationship activity-multimedia)

How can I use the related value (for example via a view, filtered on relationship) into the following fields (see ???):
1) [wpv-map-marker map_id="map-search" marker_id="marker-[wpv-post-id]" marker_field="???"
2) [types field='???' width='190' height='140' align='none'][/types]

Hope you can help.

#1524631

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

Your request relates to outputting fields from a different context, e.g. from the context of an activity use an address field that comes from a related location; from an activity display images that belong to a related multimedia post.

When you insert the shortcodes to output fields (using the Fields and Views button) a Post Selection tab is normally available where you can specify an alternate source for the data to the current post, which will add an 'item' attribute to the shortcode which specifies the other source.

But this only works where the alternate source is unique, in a one-to-many relationship for example where from a child post you want to output the title of the parent. There can be only one parent, and the item attribute will correctly identify this unique post to take the title from.

But it doesn't work the other way, where the current context is the parent post and you want to output the child post title, because there could be many child posts.

In that case you would need to create a View to display all of the possible child post titles which includes a Query Filter to specify the origin parent they belong to.

Your case is similar.

Because these are many-to-many relationships there could be many markers for that activity (even if, for a particular activity there is only one), or there could be many multimedia images for the same activity.

So in each case you need to create a new View (with a relationship Query Filter to connect it to the current activity) which in the first case will output a marker for the current location (note the shift in context) and in the second case will output the image for the current multimedia post (again, the shift in context).

Hopefully that clarifies what's required.

#1524677

Hi Nigel,

Thank you for your reply.

I have 2 views which return the required data for each activity, for example:
[wpv-view name="map-related-locations"]: "Amsterdam, Netherlands"
[wpv-view name="featured-image-related-media"]: 1 image of Amsterdam

How can I refer to these views in the following fields (inserting the views like below doesn't work right):

[wpv-map-marker map_id="map-search" marker_id="marker-[wpv-post-id]" marker_field="[wpv-view name="map-related-locations"]" marker_icon="hidden link" map_render="wait"]


[types field='[wpv-view name="featured-image-related-media"]' width='190' height='140' align='none'][/types]

Best regards, Annemarie

#1524881

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

No, you need to move those fields out of the current View into the related post Views.

You must output those shortcodes from the secondary Views which will have the correct context, not from the original View whose context is activity posts.

The image field needs to be output by the View that queries multimedia posts.

The map marker shortcode needs to be in the output of the View that queries locations.

Where in the original View you insert those fields insert the related Views instead.

#1525307

Thanks Nigel! Took some time, but thanks to your explanation I got it working - very happy with the result!