Home › Toolset Professional Support › [Resolved] adding a marker to a map
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: Africa/Casablanca (GMT+01:00)
Tagged: Toolset Maps, Views, Views API, Views plugin
Related documentation:
This topic contains 50 replies, has 3 voices.
Last updated by martinP-13 4 years, 2 months ago.
Assisted by: Jamal.
so after some digging i stubled across this hidden link
as it is it works i have asked the events calendar if they can mod it to get the venue id relatied to the organizer , i think then we could do as you said above using [tribe_venue_map] , what are your thought jamal ? thanks
using toolset i can take advantage of markers etc rather than letting the function do the settings?
have a great evening!
martin
Languages: English (English ) French (Français )
Timezone: Africa/Casablanca (GMT+01:00)
The shortcode will generate HTML, and Javascript code. We'll need a shortcode that will generate only the IDs of the posts/venues.
This part is the most interesting, but it will return all venues, we, instead, would like to get only the venues related to the current organizer. It will need somthing more to do that:
$venues = get_posts( array( 'post_type' => Tribe__Events__Main::VENUE_POST_TYPE, 'posts_per_page' => -1) );
Then we can go trough each post and get its ID:
$IDS = array(); foreach ( $venues as $venue ) { $IDS [] = $venue->ID; } // concatenate the IDs separated by (,) return implode(",", $IDS);
Then we can put all this code inside a shortcode definition, and use it on the view.
https://codex.wordpress.org/Shortcode_API
ive reached out to their support to ask how i can get the venues related to the oraniser id , thanks jamal ill let you know if i get any success but from recsent dealings the support over there isnt like here 🙂
thanks again
jamal i believe everything needed is in this file here
hidden link
could you take a peak ?
thanks martin
Languages: English (English ) French (Français )
Timezone: Africa/Casablanca (GMT+01:00)
Hello Martin,
It seems that the functions that the plugin offers/uses to get the related events is tribe_get_related_posts.
Something like this should help:
function my_related_events_func( $atts ) { $posts = tribe_get_related_posts(); $IDS = array(); foreach ( $posts as $post ) { $IDS [] = $post->ID; } // concatenate the IDs separated by (,) return implode(",", $IDS); } add_shortcode( 'my_related_events', 'my_related_events_func' );
Add this code to your functions.php file or to Toolset->Settings-> Custom code.
Then test it in your organizer post or template file. It it returns the IDs of the related evants separated by (,) we can then use it in a new view that will return the markers for these events.
thanks jamal i have added it , looking here hidden link , where would i check to see if outputted?
thanks
i echo the shortcode in the relevant php file , there is no output . i think this tribe_get_related_posts(); is used when on a single-event , but we are on a single-organizer ,
the tribe_get_related_posts(); therefore will get all the id of venues and organizers , i would need to return the related single-event THEN tribe_get_related_posts(); to get the venues........ let me have alook into this , thanks again jamal for your constant help on this
martin
Languages: English (English ) French (Français )
Timezone: Africa/Casablanca (GMT+01:00)
Thank you Martin for your feedback and your kind words.
I'll set this ticket as waiting for your feedback. It should be kept open for 3 weeks.
All the best!
Jamal
Hi Jamal so ive a little progress here .
on hidden link i have listed what event id i need to be returned before
grabbing the venue id for each event
i now have ALL event id's displaying using
function my_related_events_func( $atts ) {
$events = tribe_get_events();
foreach ( $events as $post ) {
echo '<h4>' . $post->ID . '</h4>';
}
// concatenate the IDs separated by (,)
return implode(",", $IDS);
}
add_shortcode( 'my_related_events', 'my_related_events_func' );
i have some gained the info on how to build the shortcode function but not the knowledge to do so unfortunately . so here goes
For a list of venues that the organizer has events at
1)get the list of events by the current organizer, using the "tribe_get_events" function with the current organizer ID as a meta data parameter in the $args for the query. this will show all the events related to the organizer.
2)loop through those events and grab the venues for each to create the list of venues. The tribe_get_venue_id function will take the event ID as a parameter and return the venue ID for that event.
the function tribe_get_events hidden link
the function tribe_get_venue_id hidden link
it sounds very simple but i havnt a clue how to do it . once the shortcode is built and ran in the view i think it will be perfect.
thanks as alway s jamal
martin
Languages: English (English ) French (Français )
Timezone: Africa/Casablanca (GMT+01:00)
Hello Martin,
I think, that instead of echo '<h4>' . $post->ID . '</h4>';, you should get the venue_id, put it in the IDs array and then echo it, something like this:
function my_related_events_func( $atts ) { $events = tribe_get_events(); $IDS = array(); foreach ( $events as $post ) { $venue_id = tribe_get_venue_id( $post->ID ); $IDS[] = $venue_id; } // concatenate the IDs separated by (,) echo implode(",", $IDS); }
Once you get your shortcode ready, create a view to display the venues(let's call it organizer-events-venues), and configure its query filter to only look for the provided posts in a shortcode argument, let's call it "ids". Then you would use the following:
[wpv-view name="organizer-events-venues" ids="[my_related_events]"]
thanks jamal this does now rerturn a list of venue id's now . unfortunatley not JUST the ones related the the organiser events ,
i think the function need to get the id of the organiser , ive no idea how to add that though ?
as in
using the "tribe_get_events" function with the current organizer ID as a meta data parameter in the $args for the query. this will show all the events related to the organizer.
i thin that will complete my project( i hope) sorry to harass you and thanks again for your assistance . i did think toolset would do this out of the box......
Languages: English (English ) French (Français )
Timezone: Africa/Casablanca (GMT+01:00)
WordPress provides the get_the_id function that returns the current post. In the organizer page, it will return the organizer ID. On the event page, it will return the event ID and so on.
https://developer.wordpress.org/reference/functions/get_the_id/
But according to the documentation you have provided, if no ID is provided, the function will use the current Id, which is returned by get_the_id function.
i dont know any more jamal im over my knowledge level here , maybe best to give up and move on!!
have i set the view correctly jamal ?
hidden link
Languages: English (English ) French (Français )
Timezone: Africa/Casablanca (GMT+01:00)
I am really sorry, but I am confused again. The view that you shared is querying the custom post type "Previous Trials" and I understood that we were looking for a way to get related events and venues. Maybe I was mistaken, and from the beginning we are looking for previous trials.
Please, bear with me, and explain again what you are trying to implement.
we need to ,
get the id of the organizer of the organizer post we are on
grab the event id's related to the returned organizr id
return the venue_id of any venues related to the returned event id's
prvious trials and upcoming trials are just EVENTS
so on the view hidden link
i need it to display the venues returned by the shortcode for the venue_id
am i wrong ?