dynamic content in template file?

Ed McNierney ed at TOPOZONE.COM
Thu Aug 5 17:35:14 EDT 2004


Andrew -

This will not work.

A given HTTP request (e.g.
http://www.yourserver.com/cgi-bin/mapserv?foo=foo...) gets sent to a
target handler based on the server setup, etc.  In the MapServer CGI
case, you're telling the Web server to generate the HTML (note that I
said HTML) output back to the requesting client by executing the
MapServer CGI binary and passing parameters to it.

If you're making a request to a PHP resource, the Web server will be
configured to run the PHP handler (often another CGI program) and pass
some parameters to it, including the name of the script source file.
The PHP binary runs, processes the PHP script and (optionally) the HTTP
request parameters, and generates HTML output to return to the browser.

Every HTTP request is handled by one resource.  You can't, for example,
write a PHP script that generates an ASP script to be run through the
ASP processor to generate the output.  Likewise, you can't have a CGI
program (like MapServer) write PHP script that's run through the PHP
processor to create the output.

I suppose it is theoretically possible to create a PHP script that takes
MapServer parameters as input, constructs a MapServer HTTP request,
passes that to MapServer, catches the PHP output, and runs that output
through the PHP processor.  I'm not even sure that's possible (I
couldn't think just how you would do it, but I'm not a PHP expert).

If you want to include scripting - a very reasonable thing to want -
you're better off with MapScript.  Write your PHP application and have
it use the MapScript bindings to create maps.

        - Ed

Ed McNierney
President and Chief Mapmaker
TopoZone.com
-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On
Behalf Of Andrew Koebrick
Sent: Thursday, August 05, 2004 5:16 PM
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: [UMN_MAPSERVER-USERS] dynamic content in template file?

A developer in our office is hoping to include scripting in her
mapserver template file.  Either PHP or Apache::ASP (Perl) would do.
However, I am unable to get a handler to work on the file, presumably
because the CGI version of mapserver being used bypasses those content
handlers.  We are using the Apache 2.0 server, so it seems like I should
be able to get this to work using output filters, but so far nothing but
frustration.
 
Has anyone tried and succeeded in running php or embedded perl in a
template file?
 
Andrew Koebrick
Web Coordinator / Librarian

Dept. of Administration
State of Minnesota
658 Cedar St.
St. Paul, MN 55155

651-296-4156
http://server.admin.state.mn.us
 



More information about the mapserver-users mailing list