コード例 #1
0
/**
 * Template Name: Fullscreen Map
 */
get_header('minimal');
?>


<div class="fullscreen-map-wrapper">
    <div class="fullscreen-map-sidebar">
        <div class="fullscreen-map-sidebar-inner">
            <?php 
dynamic_sidebar('fullscreen-map');
?>

            <?php 
Realia_Query::loop_properties_all();
?>
            <?php 
Realia_Query::loop_properties_filter();
?>

            <?php 
if (have_posts()) {
    ?>
                <?php 
    while (have_posts()) {
        the_post();
        ?>
                    <?php 
        include Realia_Template_Loader::locate('properties/row');
        ?>
コード例 #2
0
 /**
  * Catch template and render JSON output
  *
  * @access public
  * @return string
  */
 public static function catch_template()
 {
     if (get_query_var('properties-feed')) {
         header('HTTP/1.0 200 OK');
         header('Content-Type: application/json');
         $property_groups = array();
         $data = array();
         Realia_Query::loop_properties_all();
         Realia_Query::loop_properties_filter();
         if (have_posts()) {
             while (have_posts()) {
                 the_post();
                 // Property GPS positions. We will use these values
                 // for genearating unique md5 hash for property groups.
                 $location = get_post_meta(get_the_ID(), REALIA_PROPERTY_PREFIX . 'map_location', true);
                 $latitude = $location['latitude'];
                 $longitude = $location['longitude'];
                 // Build on array of property groups. We need to know how
                 // many and which properties are at the same position.
                 if (!empty($latitude) && !empty($longitude)) {
                     $hash = sha1($latitude . $longitude);
                     $property_groups[$hash][] = get_the_ID();
                 }
             }
         }
         wp_reset_query();
         foreach ($property_groups as $group) {
             $args = array('post_type' => 'property', 'posts_per_page' => -1, 'post_status' => 'publish', 'post__in' => $group);
             query_posts($args);
             if (have_posts()) {
                 // Group of properties at the same position so we will process
                 // property loop inside the template.
                 if (count($group) > 1) {
                     $location = get_post_meta($group[0], REALIA_PROPERTY_PREFIX . 'map_location', true);
                     $latitude = $location['latitude'];
                     $longitude = $location['longitude'];
                     // Marker
                     ob_start();
                     $template = Realia_Template_Loader::locate('google-map-infowindow-group');
                     include $template;
                     $output = ob_get_contents();
                     ob_end_clean();
                     $content = str_replace(array("\r\n", "\n", "\t"), '', $output);
                     // Infowindow
                     ob_start();
                     $template = Realia_Template_Loader::locate('google-map-marker-group');
                     include $template;
                     $output = ob_get_contents();
                     ob_end_clean();
                     $marker_content = str_replace(array("\r\n", "\n", "\t"), '', $output);
                     // Just one property. We can get current post here.
                 } else {
                     the_post();
                     $location = get_post_meta(get_the_ID(), REALIA_PROPERTY_PREFIX . 'map_location', true);
                     $latitude = $location['latitude'];
                     $longitude = $location['longitude'];
                     $content = str_replace(array("\r\n", "\n", "\t"), '', Realia_Template_Loader::load('google-map-infowindow'));
                     $marker_content = str_replace(array("\r\n", "\n", "\t"), '', Realia_Template_Loader::load('google-map-marker'));
                 }
                 // Array of values passed into markers[] array in jquery-google-map.js library
                 $data[] = array('latitude' => $latitude, 'longitude' => $longitude, 'content' => $content, 'marker_content' => $marker_content);
             }
             wp_reset_query();
         }
         echo json_encode($data);
         exit;
     }
 }