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

Crisses crisses at kinhost.org
Mon Nov 20 13:51:27 CST 2006


On Nov 20, 2006, at 1:10 PM, Craige Leeder wrote:

> Crisses wrote:
>
>> I think either you should give the full function code, or test  
>> the  value of $HeadFmt IN the function.
>>
>> Here's one problem:  What's triggering your function?  Maybe the   
>> function never runs?
>>
>> Here's another possibility for how to do what you're trying:
>>
>> $HeadFmt = '<script type="text/javascript">
>>     //<![CDATA[
>>
>>     function load() {
>>       if (GBrowserIsCompatible()) {
>>         var map = new GMap2(document.getElementById("' .
>> $GoogleMapDefaults['id'] . '"));
>>       }
>>     }
>> ' . MoreTextFunction() . '
>>     //]]>
>>     </script>';
>>
>> then do whatever you need in MoreTextFunction() and have it  
>> return  the javascript text you want pasted into $HeadFmt:
>>
>>          return 'map.setCenter(new GLatLng(' . $ParsedArgs['lon'] .
>> ', ' . $ParsedArgs['lat'] . '), ' . $GoogleMapDefaults['zoom'] .  
>> ');';
>>
>> And see if that works.
>>
>> Crisses
>
>
> Well the function IS being run, it is called by a cvtMarkup()  
> function, which you will see in a moment. I have made sure it has run.
>
> I can't do the seccond method, as the javascript is dynamically  
> generated throught multiple funcitons.

A function can call other functions.

>
> Here is the code I have so far.
>
> <?php
>
> /* Set Defaults
>  */
>
> // Config Defaults
> SDV( $GoogleMapKey, '' );
> SDV( $GoogleMapDefaults, array( 'width' => '300',
>                                'height' => '300',
>                                'id' => 'map',
>                                'view' => 'normal',
>                                'zoom' => '11',
>                                'lon' => '42.72500',
>                                'lat' => '-81.200935'
>                                ) );
>
> $PasedArgs &= $GoogleMapDefaults;
> // HTMLHeader Defaults
> $HTMLHeaderFmt[] = '<script src="http://maps.google.com/maps? 
> file=api&amp;v=2&amp;key=' . $GoogleMapKey . '"
>            type="text/javascript"></script>';
>           $HeadFmt = '<script type="text/javascript">
>    //<![CDATA[
>
>    function load() {
>      if (GBrowserIsCompatible()) {
>        var map = new GMap2(document.getElementById("' .  
> $GoogleMapDefaults['id'] . '"));
>      }
>    }';
>
>   // Markup() Calls
> Markup( 'map', '_begin', '/\(:map(-location\s|\s)(.*?):\)/ie',  
> "CvtMarkup('$1', '$2')" );

Note that this is parsing $1 and $2 before they're defined. At the  
time the Markup is being defined $1 and $2 are blank.  Try:

Markup( 'map', '_begin', '/\(:map(-location\s|\s)(.*?):\)/ie',  
"CvtMarkup('\$1', '\$2')" );

or:

Markup( 'map', '_begin', '/\(:map(-location\s|\s)(.*?):\)/ie',  
'CvtMarkup("$1", "$2")' );

I don't fully understand how to escape the function call properly;  
someone else might have to help you with that one if these don't  
work.  What you want is to store the function and variable names so  
that Markup can run them later.


Let me know if that doesn't help.

Crisses
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/pmwiki-devel/attachments/20061120/e857ac90/attachment.html 


More information about the pmwiki-devel mailing list