WordPress.org

Ready to get started?Download WordPress

Forums

SimpleMap Store Locator
[resolved] [Plugin: SimpleMap] Search shows map results but doesn't link to them? (14 posts)

  1. chrisdoth
    Member
    Posted 3 years ago #

    Have found my general wordpress search box brings up results from the simplemap however when clicked on these bring up an error page.

    Is there a way to either stop the search indexing the simplemap or else a fix to the links?

    http://wordpress.org/extend/plugins/simplemap/

  2. chrisdoth
    Member
    Posted 3 years ago #

    Do we know?

  3. Glenn Ansley
    Member
    Plugin Author

    Posted 3 years ago #

    Have you modified the plugin? At all? The post type should be registered to not show up in posts and I haven't gotten this bug report before?

    Make sure that the sm-location post type is registered as publically_queryable => false

    http://plugins.trac.wordpress.org/browser/simplemap/trunk/classes/locations.php#L23

  4. chrisdoth
    Member
    Posted 3 years ago #

    Hi, Thank you for the reply. No, I haven't moded the plugin.

    I notice the links also don't work on the admin side, if I click 'View' on the 'Edit Locations' page I get the same broken link for listings. This is my sites domain name followed by;

    /?sm-location=

    With the pages title. which gives and error 404 page?

  5. mslater88
    Member
    Posted 3 years ago #

    I've installed this on a new WP installation, deleted everything and started from scratch with no other plugins, etc. and I'm also getting this exact scenario. I have not modified anything.

    http://goretail.ca/?sm-location=the-great-canadian-meat-company

  6. Glenn Ansley
    Member
    Plugin Author

    Posted 3 years ago #

    This is fixed in 2.3.3
    You can get an advanced version of this with premium support if you'd like, but all you need to do to fix this is to follow the instructions below (I'm giving you the entire function to replace, but its one line... you're adding exclude_from_search = true,.

    Find this function:

    function register_locations(){
    
    	$args = array(
    		'public' => true,
    		'publicly_queryable' => false,
    		'show_ui' => true,
    		'capability_type' => 'post',
    		'hierarchical' => true,
    		'rewrite' => false,
    		'query_var' => 'sm-location',
    		'register_meta_box_cb' => array( &$this, 'location_meta_cb' ),
    		'supports' => array(),
    		'labels' => array(
    			'name' => 'Locations',
    			'singular_name' => 'Location',
    			'add_new_item' => 'Add New Location',
    			'edit_item' => 'Edit Location',
    			'new_item' => 'New Location',
    			'view_item' => 'View Locations',
    			'search_items' => 'Search Locations',
    			'not_found' => 'No Locations found',
    			'not_found_in_trash' => 'No Locations found in trash',
    		)
    	);
    	// Register it
    	register_post_type( 'sm-location', $args );
    }

    and replace it with this one

    function register_locations(){
    
    	$args = array(
    		'public' => true,
    		'publicly_queryable' => false,
                    'exclude_from_search' => true,
    		'show_ui' => true,
    		'capability_type' => 'post',
    		'hierarchical' => true,
    		'rewrite' => false,
    		'query_var' => 'sm-location',
    		'register_meta_box_cb' => array( &$this, 'location_meta_cb' ),
    		'supports' => array(),
    		'labels' => array(
    			'name' => 'Locations',
    			'singular_name' => 'Location',
    			'add_new_item' => 'Add New Location',
    			'edit_item' => 'Edit Location',
    			'new_item' => 'New Location',
    			'view_item' => 'View Locations',
    			'search_items' => 'Search Locations',
    			'not_found' => 'No Locations found',
    			'not_found_in_trash' => 'No Locations found in trash',
    		)
    	);
            // Register it
    	register_post_type( 'sm-location', $args );
    }
  7. chrisdoth
    Member
    Posted 3 years ago #

    Thats great Glen. I'll update the file now.

  8. solace10
    Member
    Posted 3 years ago #

    That's cool - but now the search result won't show up.

    Is it possible to enable the WordPress search result to link to the map page somehow?

  9. mrose17
    Member
    Posted 2 years ago #

    i suspect that if you change 'publicly-queryable' from false to true, you will find joy.

  10. mirefoot
    Member
    Posted 2 years ago #

    That all worled a treat

    How do we get the listing of the locations in the search result to link to the actual custom post?

  11. mrose17
    Member
    Posted 2 years ago #

    if we are talking about simplemap 2.2.5, then:

    step 1: get the search helper to include the permalink in the results, that's easy:

    --- _xml-search.php	2011-07-27 20:07:22.000000000 -0700
    +++ xml-search.php	2011-09-24 00:26:21.000000000 -0700
    @@ -205,6 +205,7 @@
     						$newnode 	= $markers->addChild( 'marker' );
     					}
    
    +					$newnode->$attr_func( "plink", esc_attr( get_permalink( $location->ID ) ) );
     					$newnode->$attr_func( "name", apply_filters( 'the_title', $location->post_title ) );
     					$newnode->$attr_func( "description", apply_filters( 'the_content', $location->post_content ) );
     					$newnode->$attr_func( "lat", esc_attr( $location->lat ) );
    @@ -240,6 +241,7 @@
     				$markers = array();
     				foreach ( $dataset as $key => $location ) {
     					$fields = array(
    +						'plink' => esc_attr( get_permalink( $location->ID ) ),
     						'name' => apply_filters( 'the_title', $location->post_title ),
     						'description' => apply_filters( 'the_content', $location->post_content ),
     						'lat' => esc_attr( $location->lat ),

    step 2: make use of it in classes/simplemap.php - i'm not including the code for this (because i'm not satisfied with the changes i've made); however, here's what to do:

    go to the javascript function searchLocationsNear(). you'll see this:

    for (var i = 0; i < markers.length; i++ ) {
    						var name = markers[i].getAttribute('name');

    add a new variable there:

    var plink = markers[i].getAttribute('plink');

    later on you will see two calls that look like this:

    var marker = createMarker(...);
    ...
    varsidebarEntry = createSidebarEntry(...);

    add plink as a parameter to each them. then scroll down the file until you find these two javascript functions. add the parameter to each and then make use of it however you want.

    for example, instead of putting up the website url you could put up a link that says "More Details" with the permalink.

    finally, although i have had great success making a few changes and fixing a few minor bugs with this plugin, i'm probably going to move to the premium version soon, simply because i don't want to have to keep backporting the diffs.

  12. mirefoot
    Member
    Posted 2 years ago #

    Thank you so much, it all works great.

    For anyone else, this is the finished line after making the changes described above...

    html += '<h3 style="margin-top: 0; padding-top: 0; border-top: none;"><a href="' + plink + '">' + name + '</a>';

  13. Glenn Ansley
    Member
    Plugin Author

    Posted 2 years ago #

    I love to see community support. Thanks for the code. The 2.4 beta is available to premium subscribers and includes the ability to change the permalink slug and automatically place location data on that page once you get there.

    2.4 will eventually make it to .org/extend...

  14. mirefoot
    Member
    Posted 2 years ago #

    When you say automatically puts location data on the location page, do you mean I can add a map of the single location that thislocation post refers to as that is my next challenge...

    How do I put a map of the single location on that location's page?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic