MichDe / wordpress-geo-mashup

Automatically exported from code.google.com/p/wordpress-geo-mashup
1 stars 0 forks source link

Area-Links-List or Anchor-Links for Countries #583

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi, 
thanks for this great plugin!

Instead a list of posts by area I would suggest a simple list of areas linked 
to the index.php - like terms. For better overview, as the post list is simply 
to long. 

If this is to complicated, I would suggest anchors by country - so I could link 
the different areas. 
To give you an example: http://berufebilder.de/karte/#ca

I did it manually, but its to complicated as the list changes allways. Trying 
to put anchors in the following code, I didn't get managed. 

Can anybody help me?

It has to be something like: $country_heading = '<h3 id="country_name">' . 
$country_name . '</h3>';

Thanks for your help! 
See below the full code. 

Simone

    /**
     * List located posts by area template tag.
     *
     * Returns an HTML list of all located posts by country and state. May try to look up 
     * this information when absent.
     *
     * @since 1.2
     * @link http://code.google.com/p/wordpress-geo-mashup/wiki/TagReference#List_Located_Posts_By_Area
     *
     * @param string|array $args Template tag arguments.
     * @return string List HTML.
     */
    public static function list_located_posts_by_area( $args ) {
        $args = wp_parse_args( $args );
        $list_html = '<div class="gm-area-list">';
        $countries = GeoMashupDB::get_distinct_located_values( 'country_code', array( 'object_name' => 'post' ) );
        $country_count = count( $countries );
        $country_heading = '';
        foreach ( $countries as $country ) {
            if ( $country_count > 1 ) {
                $country_name = GeoMashupDB::get_administrative_name( $country->country_code ); 
                $country_name = $country_name ? $country_name : $country->country_code;
                $country_heading = '<h3>' . $country_name . '</h3>';
            }
            $states = GeoMashupDB::get_distinct_located_values( 'admin_code', 
                array( 'country_code' => $country->country_code, 'object_name' => 'post' ) );
            if ( empty( $states ) ) {
                $states = array( (object) array( 'admin_code' => null ) );
            }
            foreach ($states as $state ) { 
                $location_query = array( 
                    'object_name' => 'post',
                    'country_code' => $country->country_code,
                    'admin_code' => $state->admin_code,
                    'sort' => 'post_title'
                );
                $post_locations = GeoMashupDB::get_object_locations( $location_query );
                if ( count( $post_locations ) > 0 ) {
                    if ( ! empty( $country_heading ) ) {
                        $list_html .= $country_heading;
                        $country_heading = '';
                    }
                    if ( null != $states[0]->admin_code ) {
                        $state_name = GeoMashupDB::get_administrative_name( $country->country_code, $state->admin_code );
                        $state_name = $state_name ? $state_name : $state->admin_code;
                        $list_html .= '<h4>' . $state_name . '</h4>';
                    }
                    $list_html .= '<ul class="gm-index-posts">';
                    foreach ( $post_locations as $post_location ) { 
                        $list_html .= '<li><a href="' . 
                            get_permalink( $post_location->object_id ) .
                            '">' .
                            $post_location->label .
                            '</a>';
                        if ( isset( $args['include_address'] ) && $args['include_address'] == 'true' ) {
                            $list_html .= '<p>' . $post_location->address . '</p>';
                        }
                        $list_html .= '</li>';
                    }
                    $list_html .= '</ul>';
                }
            }
        }
        $list_html .= '</div>';
        return $list_html;
    }

Original issue reported on code.google.com by berufebi...@gmail.com on 11 Jul 2012 at 8:18

GoogleCodeExporter commented 9 years ago
I think issue 523 will take care of this.

Original comment by dylankk...@gmail.com on 25 Jul 2012 at 3:05