WordPress.org

Ready to get started?Download WordPress

Forums

Store Locator Plus
[resolved] slp_javascript_results_string Returning Results Twice (3 posts)

  1. Simalam
    Member
    Posted 1 year ago #

    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/

  2. Charleston Software Associates
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. Simalam
    Member
    Posted 1 year ago #

    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>';
         }
     }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.