[mapguide-users] Passing variables into MGOS [No Viruses detected]

mauro1970 mgvillablanca at yahoo.com
Thu May 22 15:02:54 EDT 2008


A little bit late here's how you pass ONE parameter to Mapguide:

Mapguide creates internal parameters when a web layout is loaded. External
parameters can be sent to Mapguide Open Source by modifying the Mapguide API
and editing the files mainframe.php, taskframe.php, mainframe.templ.
taskframe.templ. The PHP scripts are located under www/mapviewerphp and the
templates under www/viewerfiles in the Mapguide installation folder.

mainframe.templ and mainframe.php:
The mainframe.php script loads and formats the mainframe.templ template when
a web layout is viewed in the browser. The following change must be made to
the template:

Add the parameter as variable at the beginning of the script, i.e.: 
var externalParam = '%s';
The %s wildcard represents a variable which value will be inserted in that
line when the template is loaded via the sprintf PHP function.

Add the variable representing the parameter to the params array populated in
the AddStdParams function, i.e.
	params.push("externalParam");  params.push(externalParam);

Add the variable representing the parameter to the URL generated in the
MakeUrl function, i.e.
	url += ..... + "&externalParam=" + externalParam;

Once the template has been updated, proceed to edit the mainframe.php
script. Declare a variable at the beginning of the Mainframe.php script,
i.e. 
$externalParam = '';

Then declare it as a global variable in the BuildViewer function, i.e.
global $externalParam;

The variable is then passed to the task pane when Mapguide loads the layout
by modifying the $srcTaskFrame variable and adding the parameter to the URL,
i.e.
$srcTaskFrame = <code>   . '&externalParam=' . $externalParam . <code>

The variable that represents the parameter must also be added to the $templ
variable when formatting the mainframe.templ template by inserting the
variable in the correct order, i.e.
print sprintf($templ, <variables>, $externalParam, <variables>

Then declare a global variable representing the parameter in the
GetParameters function and set it, i.e.
	if(isset($params['externalParam'])) {
       		 $externalParam = $params['externalParam'];
    	} else { externalParam = '';}

taskframe.templ and taskframe.php:
The mainframe.php script also executes the taskFrame.php script that formats
the taskframe.templ template when a web layout is viewed in the browser. The
following change must be made to the template:

Add the additional parameter to the source of the taskPaneFrame frame at the
end of the remplate, i.e.:
Src=”... &LOCALE=%s&externalParam=%s" noresize>

Make the following changes to the the taskframe.php script:
Declare the variable that represents the parameter at the beginning of the
script, i.e.:
$externalParam = '';
Add the same variable in the correct order to the sprintf function that
formats the taskframe.templ template, i.e.:
sprintf($templ, GetSurroundVirtualPath() . "tasklist.php", $locale,
$taskPane, $session, urlencode($webLayout), $dwf, $locale, $externalParam);

Declare and set the same variable in the GetParameters fuction, i.e.:
global $externalParam;
Then
$externalParam = $params['externalParam'];
	
After these changes, pass a parameter to Mapguide by adding the parameter to
the web layout’s URL, e.g.
http://server/mapguide/mapviewerajax/?WEBLAYOUT=Library%3a%2f%2ftest%2fWeb_Layouts%2fAll.WebLayout&LOCALE=en&externalParam=foo.

The external parameter will be passed to the task frame when Mapguide loads
a web layout. If it’s not added, Mapguide will set it as a empty string.

-- 
View this message in context: http://www.nabble.com/Passing-variables-into-MGOS--No-Viruses-detected--tp7701810p17411284.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list