CartoWeb 3.4.0
Download Now!

Advanced Geographical Information System for the Web

How to return a variable from the server-side to the client-side of a plugin

server side

/* you can do this in any of the server entry points 
   ( initialize, initializeRequest, overrideRequest, 
   handlePreDrawing, handleDrawing, handlePostDrawing)
   the only important thing is the new class instanciation. */

public function initializeRequest($request) {

    $result = new YourReturnedObjectFromServer();
    $result->yourVar = "blabla";

    return $result;


client side

/* recover the result object comming from server side
   apply all treatments needed before assigning the 
   variables in the template via renderform */

public function initializeResult($serverResult) {
    if (is_null($serverResult))

    $this->someVariable = $serverResult->yourVar;


/* define the returned object */

class YourReturnedObjectFromServer extends CwSerializable {

     * A String returned from server
     * @var string
    public $yourVar;
    public function unserialize($struct) {
        $this->yourVar = self::unserializeValue($struct, 'yourVar');


<complexType name="YourReturnedObjectFromServer">
      <element name="yourVar" type="xsd:string"/>

CartoWeb Wiki: HowToReturnDataFromServerToClient (last edited 2020-09-25 05:58:51 by OliverChristen)

© 2002-2007 CartoWeb by Camptocamp SA - Wiki powered by MoinMoin