Support » Plugin: Store Locator Plus for WordPress » slp_javascript_results_string Returning Results Twice

  • Resolved Simalam

    (@simalam)


    Hello,

    I am trying to use this action to modify the way the results are displayed on our website and I am getting each result repeated twice right after each result.

    The slp_javascript_results_string example on your website also returns the results twice.

    For example from your site but result string changed

    // Search Functionality Hook
     //
     add_filter('slp_javascript_results_string',
     array('SLPEnhancedResults','mangle_results_output'),
     90
     );
    /**
     * Main SLP Enhanced Results Class
     */
     class SLPEnhancedResults {
    /**
     * Method: mangle_results_output
     */
    function mangle_results_output($resultString) {
     return preg_replace('/.*/',
     'test'
     ,
     $resultString);
     }
     }

    Will display the words “testtest” for every result

    http://wordpress.org/extend/plugins/store-locator-le/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Store Locator Plus

    (@charlestonsw)

    What happens if you just return ‘test’ in the mangle_results_output method?

    Also – make sure you are in fact only getting one result back by looking at the JSON response or HTML output with a web browser dev tool.

    Must have been something with the preg_replace. If I return just a ‘test’ string, it displays just “test”.

    I returned a simple string with the html and JavaScript format string positional placeholders I wanted to use and its working great.

    Thanks!

    // Search Functionality Hook
     //
     add_filter('slp_javascript_results_string',
     array('SLPEnhancedResults','mangle_results_output'),
     90
     );
    /**
     * Main SLP Enhanced Results Class
     */
    class SLPEnhancedResults {
        /**
         * Method: mangle_results_output
         */
         function mangle_results_output($resultString) {
             return '{0} is {1} {2} away.<br/>' . '<a href="http://{10}/maps?saddr={11}&daddr={12}" target="_blank">Get directions.</a>';
         }
     }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘slp_javascript_results_string Returning Results Twice’ is closed to new replies.