[pmwiki-devel] New Recipe Code Problem: HTMLHeadFmt.

Craige Leeder craige at internetadvisor.ca
Fri Nov 17 16:01:12 CST 2006


Well, I guess it's not *really* about HTMLHeadFmt, but that is the 
closest comparison I could make for you to get what I'm looking for help 
with from the subject.

The problem is actually a different variable. A custom one: $HeadFmt. I 
am using the variable to store javascript throught the recipe exicution, 
and add to HTMLHeadFmt at the end of the script. However, I'm having a 
problem with the code in my callback function not being able to add to 
the HeadFmt variable.

The HeadFmt variable was origonally defined outside the function, but it 
was declared global within it, so it can be used. I have echoed it out 
from within the function, but it only seems to contain what was set 
outside the function. My additional code is not added to it.

The code I am working on is a light version of the Google API. I 
origonally started it because of the need for address related 
coordinates, seing as how the current API doesn't have that 
functionality, and I require it.

Here is the related code:

Set outside the function:

$HeadFmt = '<script type="text/javascript">
    //<![CDATA[

    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("' . 
$GoogleMapDefaults['id'] . '"));
      }
    }';

Inside the function:

     // Check the location paramater
     if ( preg_match('/"(.*\s*)?"/', $params['location']) )
     {
         echo true; // debugging check
         $loctype = 'addr'; // It's an address
         $ParsedArgs['location'] = str_replace('"', '', 
$params['location']);
     }
     else
     {
         $loctype = 'll'; // It's a longitude and latitude
         $ll = explode( ',', $params['location'] );
         $ParsedArgs['location'] = array( 'lon' => $ll[0], 'lat' => 
$ll[1] );
        
         $HeadFmt .= 'map.setCenter(new GLatLng(' . $ParsedArgs['lon'] . 
', ' . $ParsedArgs['lat'] . '), ' . $GoogleMapDefaults['zoom'] . ');';
     }

    $HeadFmt .= '    //]]>
    </script>';

    echo $HeadFmt; // Test

When I echo out $HeadFmt, it only  contains that set outside the function.

Maybe it's just me sitting at the computer too long, and maybe I'm just 
missing something. If you see anything, please, let me know.

That should be all the related code you need, but if not, let me know.

- Craige
-- InternetAdvisor




More information about the pmwiki-devel mailing list