Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Ian Dunn

    (@iandunn)

    Hi Harry, the details property is just the placemark post’s content, so there are 3 ways you can add to it:

    • Change the content of the post manually in the WYSIWYG editor.
    • Add a callback for WordPress’ core the_content filter
    • Add a callback for the bgmp_get-placemarks-return filter. You’ll get a multidemensional array of placemark passed in, and you can loop through them and modify the details item for each placemark. In version 1.8, the individual arrays don’t have ID fields, so you’ll have to lookup the posts based on the slug, but I’ll add the ID field for v1.9.
    Thread Starter harry

    (@stevenharrisdesigns)

    Thanks Ian, The last option is the best for me, sorry for not getting back to you earlier, could you possible add an example of for adding say “Hello World” to the end of the each post, if its no too much trouble. I don’t have any experience with callbacks but understand the concept, I also think that this might help others?

    I know I have done this completely the wrong way, for updates ect, but this is my current solution and would really like to know the correct way of doing this. I have edited your getMapPlacemarks() function on line 999 of core.php

    foreach( $publishedPlacemarks as $pp )
    {
    	$icon = wp_get_attachment_image_src( get_post_thumbnail_id( $pp->ID ) );
    	$defaultIcon = apply_filters( self::PREFIX .'default-icon', plugins_url( 'images/default-marker.png', __FILE__ ), $pp->ID );
    
    	$connected_placemarks = '';
    	$connected = p2p_type( 'project_to_bgmp' )->get_connected( $pp->ID );
    	while( $connected->have_posts() ) : $connected->the_post();
    	$connected_placemarks .= '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
    	endwhile;
    
    	$placemarks[] = array(
    		'title'		=> $pp->post_title,
    		'latitude'	=> get_post_meta( $pp->ID, self::PREFIX . 'latitude', true ),
    		'longitude'	=> get_post_meta( $pp->ID, self::PREFIX . 'longitude', true ),
    		'details'	=> wpautop( $pp->post_content ).'<ul>'.$connected_placemarks.'</ul>',
    		'icon'		=> is_array( $icon ) ? $icon[0] : $defaultIcon,
    		'zIndex'	=> get_post_meta( $pp->ID, self::PREFIX . 'zIndex', true )
    	);
    }
    Plugin Author Ian Dunn

    (@iandunn)

    Hi harry, this this in a functionality plugin or your theme:

    function editPlacemarkDetails( $placemarks )
    {
    	foreach( $placemarks as &$placemark )
    		$placemark[ 'details' ] .= 'hello world';
    
    	return $placemarks;
    }
    add_filter( 'bgmp_get-placemarks-return', 'editPlacemarkDetails' );
    Thread Starter harry

    (@stevenharrisdesigns)

    Thanks so much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Basic Google Maps Placemarks] hook to add to details’ is closed to new replies.