Opened 19 years ago

Last modified 19 years ago

#1300 assigned defect

[layers] tag not processed by mapObj->processtemplate()

Reported by: mbasa@… Owned by: mapserverbugs
Priority: high Milestone:
Component: MapScript-PHP Version: 4.4
Severity: normal Keywords:
Cc:

Description

mapObj->processtemplate() always leaves the [layers] tag empty even though there
are valid set layers (status=on/default) within the map ( i.e. <h1> '[layers]'
</h1>  =>  <h1> ' ' </h1>  )

Change History (2)

comment:1 by dmorissette, 19 years ago

Cc: steve.lime@… added
Status: newassigned
I had a look at this, and it's seem that it's this way by design. I'll CC Steve
to see if he thinks that we should change something.

The [layers] tag in the template is intended to return a space-delimited list of
layer names that were passed to the layers parameter in the mapserv CGI URL by
the previous request. In the context of MapScript, this tag has no direct mapping.

I understand that you'd like to have a way to return the list of layers that
currently have their status set to MS_ON or MS_DEFAULT in the map object, but
that's slightly different from what the [layers] tag was designed form which is
only to carry the values that were previously set by the client in the request URL.

What you'd have to do is use your own custom [mylayers] tag for instance:

  $params['mylayers'] = '';
  for($i=0; $i < $map->numlayers; $i++)
  {
    $layer = $map->getLayer($i);
    if ($layer->name && 
        ($layer->status == MS_ON || $layer->status == MS_DEFAULT) )
    {
        $params['mylayers'] .= $layer->name . ' ';
    }
  }
  $output = $map->processTemplate($params, MS_TRUE);


comment:2 by mbasa@…, 19 years ago

I had to do something like the sample code to get the [layers] tag working in
PHP Mapscript. Since the tag works in the CGI mapserver and is part of the
template documentation, we are getting questions here why it does not behave
simillar in PHP Mapscript.
Note: See TracTickets for help on using tickets.