[mapguide-users] What is %24CurrentSelection???

Chris Claydon chris.claydon at autodesk.com
Wed Mar 18 10:36:47 EDT 2009


You should be able to include this code at the beginning of your own php file. I believe it is called date.php. This file presumably does something useful with the information about the current selection. You should be able to retrieve the information you need from the MgSelection object using some simple php calls instead of calling echo $selection->ToXml().

>From your original screenshots it looks like you have already managed to create an InvokeURL command in MapGuide Studio, but if you have specific questions about the process, let me know.

Chris.


-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of achectl
Sent: Tuesday, March 17, 2009 10:52 PM
To: mapguide-users at lists.osgeo.org
Subject: RE: [mapguide-users] What is %24CurrentSelection???


Thanks a lot Chris

Which file I need to modify and copy & place the below PHP code to that file
for testing? I will try to modify the code. Note: I will change the path for
webconfig.ini. :-( I need to complete the invokeURL problem asap. What is
the proper way to do InvokeURL of MapGuide Studio? 

Thanks
Achectl


Chris Claydon wrote:
> 
> In a basic web layout, I'm pretty sure $CurrentSelection returns you the
> current selection in XML format. This corresponds to the string you get if
> you call ToXml() on an MgSelection object using the web tier API.
> 
> It appears that the flexible web layout code does not treat
> $CurrentSelection as a special case, and simply returns the URL-encoded
> version of variable name itself.
> 
> The solution is to get hold of the MgSelection object for the current map
> selection within the invoked PHP code. The following PHP code will dump
> out the selection XML. You should be able to extend it pretty easily to
> extract exactly what you need from the selection...
> 
> (Note that you may need to adjust the path to the webconfig.ini file in
> the call to MgInitializeWebTier)
> 
> Hope this helps,
> 
> Chris.
> 
> <?php
>     
>     $mapName = "";
>     $sessionId = "";
>         
>     try 
>     {
>         // Initialize the web tier API
>         MgInitializeWebTier("C:/Program
> Files/Autodesk/MapGuideEnterprise2009/WebServerExtensions/www/webconfig.ini");
>         
>         // Read the map name and session ID
>         GetRequestParameters();
> 
>         // Create a site connection
>         $user = new MgUserInformation($sessionId);
>         $siteConnection = new MgSiteConnection();
>         $siteConnection->Open($user);
>         
>         // Create a resource service instance
>         $resourceService = $siteConnection->CreateService(0);
>                 
>         // Retrieve the selection
>         $selection = new MgSelection();
>         $selection->Open($resourceService, $mapName);
>         
>         // Output the selection
>         echo $selection->ToXml();
>     }
>     catch(MgException $e) 
>     {
>         // Output error details
>         echo "<Message>" . $e->GetMessage() . "</Message>";
>         echo "<Details>" . $e->GetDetails() . "</Details>";
>     }
>         
>         
>     function GetParameters($params)
>     {
>         global $mapName;
>         global $sessionId;
> 
>         $mapName = $params['MAPNAME'];
>         $sessionId = $params['SESSION'];
>     }
> 
>     function GetRequestParameters()
>     {
>         if($_SERVER['REQUEST_METHOD'] == "POST")
>             GetParameters($_POST);
>         else
>             GetParameters($_GET);
>     }
> ?>
> 
> 
> 



More information about the mapguide-users mailing list