Home › Forums › MapPress Support › Template tag
- This topic has 8 replies, 2 voices, and was last updated 11 years, 2 months ago by
Chris.
-
AuthorPosts
-
October 1, 2012 at 7:56 am #10510
manunc
ParticipantHello,
I need to display a map configured on admin side in a specific post, I see that each new created map have an ID.
The tag to use is the following
<?php echo do_shortcode('[mappress mapid="20"]'); ?>
but how catch the map ID so that the query is working for every post?
stg like:
$mapid = get_post_mapid('TEST');
<?php echo do_shortcode('[mappress mapid="$mapid"]'); ?>
Thanks for your help
October 1, 2012 at 8:42 am #10511Chris
KeymasterHi, what version of the plugin are you using?
October 1, 2012 at 8:46 am #10512Chris
KeymasterHi,
Here’s how you can get a list of maps for the post, then use the first map in the list:
$maps = Mappress_Map::get_post_map_list($post->ID);
if (!empty($maps)) { $mapid = $maps[0]->mapid; do_shortcode('[mappress mapid="$mapid"]'); }
October 1, 2012 at 8:46 am #10513manunc
ParticipantThe last one I guess:
Version:2.38.6 PROOctober 1, 2012 at 8:48 am #10514manunc
ParticipantThanks,
Is there a way to directly get the mapid by filtering, giving the name of the map in argument ?
exemple: a map id 2 has the name [2] Couleur du Lagon
October 1, 2012 at 8:58 am #10515Chris
KeymasterHi, no there’s no way to search by name. If you’re just searching for one name in the current post, you could loop through the results from the get_post_map_list() function call.
October 1, 2012 at 8:28 pm #10519manunc
ParticipantHello,
I have disable automatic display in MapPress settings and I have added this in my listing.php page:
<section id=”overview”>
<?php the_content(); ?>
<?php $maps = Mappress_Map::get_post_map_list($post->ID);if (!empty($maps)) {
$mapid = $maps[0]->mapid;
do_shortcode(‘[mappress mapid="$mapid"]‘);
} ?></section>
Unfortunately no map is displayed
Any idea?
October 1, 2012 at 10:15 pm #10521manunc
ParticipantI have almost finished the integration but I have a little issue:
I used the following code to display the map:
$coord = appthemes_get_coordinates( $post->ID );
$mymap = new Mappress_Map( array(
“width” => 750,
“center”=> array(“lat” => $coord->lat, “lng” => $coord->lng),”zoom” => 19 )
);
echo $pro;
$mypoi_1 = new Mappress_Poi(array(
“title” => $pro,
“body” => $pro,
“point” => array(“lat” => $coord->lat, “lng” => $coord->lng)
));
$mymap->pois = array($mypoi_1);
echo $mymap->display();But $pro that is retrieved with:
<?php $pro = the_title(); ?>
Does not show the title in the map,
Any idea?
October 2, 2012 at 6:38 am #10528Chris
KeymasterHi,
I wasn’t clear – is the_title() actually set but just not displaying in the map? For example, if you print it instead of trying to map it, do you see it has a value:
print_r(the_title());
What happens if you just hardcode the map title, e.g.
…title => ‘hello’…
If that’s not the issue, you could take a look at the poi template file to see if perhaps it’s not generating the HTML the way you need it. The file is:
/pro/templates/map_poi.php
-
AuthorPosts
- You must be logged in to reply to this topic.