Support » Plugin: Stellar Places » Template trouble

  • Resolved JamesSFastnet

    (@jamessfastnet)


    Hi Devs!

    First, thanks for the plugin, it promises to do everything I need. I did have quite a bit of trouble getting it working though, so in case anyone else is pulling their hair out, this is what happened:

    I did a fresh install and copied a custom infowindow template to my theme directory.
    The infowindow was only printing out the variable names and not the values.
    Much debugging followed (verifying that the JSON passed was correct, that the templating engine worked, that everything backbone.js and underscore.js worked fine on a simple test page without the plugin).
    I narrowed the problem down to the template actually being included without the <%= %> necessary for it to be parsed by the scripts. (So for instance <%= name => was included as name).
    I fixed it by changing google-map.php with the following:

    public static function wp_print_footer_scripts() {
    		$template = locate_template( 'stellar-places/info-window.html' );
    
    		if ( empty( $template ) ) {
    			$template = dirname( STELLAR_PLACES_FILE ) . '/includes/templates/info-window.html';
    		}
    
    		// Added this.
    		$template_string = file_get_contents($template);
    
    		echo '<script type="text/template" id="stellar-places-info-window-template">';
    		// Removed this.
    		//include( $template );
                    //Added this.
    		echo $template_string;
    		echo '</script>';
    	}

    No idea why “include” didn’t work, but there you go.

    https://wordpress.org/plugins/stellar-places/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Micah Wood

    (@woodent)

    @jamessfastnet,

    Interesting problem. I’m not able to replicate that, so it is most likely an environment issue. What can you tell me about your hosting/server setup that might shed some light on this?

    Hi Micah,

    Thanks for the replay. Here is the server information from my CPanel interface:

    cPanel Version 11.44.1 (build 17)
    Theme paper_lantern
    Apache Version 2.2.27
    PHP Version 5.4.31
    MySQL Version 5.5.37-cll
    Architecture x86_64
    Operating System linux

    @jamessfastnet

    What version of WP?

    WordPress version is 3.9.2

    Plugin Author Micah Wood

    (@woodent)

    @jamessfastnet,

    I’m not sure why the include() function is working differently for you than it is for me… especially since I’m running a very similar stack.

    As a best practice, however, I’ve learned that the include() function is intended for including and evaluating PHP files whereas file_get_contents() is more appropriate for this use case.

    So, thanks for bringing this up. I’m going to change the function that I’m using to adhere to best practices as well as to fix your issue. The update will be in the next release, so you don’t need to worry about the update breaking anything you’ve gotten working.

    Plugin Author Micah Wood

    (@woodent)

    @jamessfastnet,

    As of version 1.0.2, the plugin uses file_get_contents() instead of include(). Marking as resolved. Thanks for finding this bug!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Template trouble’ is closed to new replies.