[Chameleon] Custom Query Results

Tracy Howlett thowlett at whistlermuseum.org
Sat May 8 18:45:01 EDT 2004


Thanks Paul - that did just the trick.

And now for more questions...is there a way to have the query result contain
a URL to a document?  If I include the URL in a field can I have the display
results say 'Click here for more info' instead of actually listing the URL?

Tracy

-----Original Message-----
From: chameleon-bounces at lists.maptools.org
[mailto:chameleon-bounces at lists.maptools.org] On Behalf Of Paul Spencer
Sent: Tuesday, April 20, 2004 1:09 PM
To: thowlett at whistlermuseum.org
Cc: chameleon at lists.maptools.org
Subject: Re: [Chameleon] Custom Query Results

Tracy,

I think that the important part of QueryResults.phtml starts around line 
376 (in my version which is the latest from CVS) and looks like this:

// loop and use key for titles
             foreach ($aRows[0] as $key => $value)
             {
                 $szReturnValue .= "<td class=\"subContentArea2\"><p 
class=\"text\">".$key."</p></td>\n";
             }
             $szReturnValue .= "</tr>\n";

             // loop through the results and format each row
             foreach ( $aRows as $aRow )
             {
                 // add a row for each
                 $szReturnValue .= "<tr>\n";

                 // loop and add a cell for each result
                 foreach ( $aRow as $xCell )
                 {
                     $szReturnValue .= "<td class=\"subContentArea1\"><p 
class=\"text\">". $xCell."</p></td>\n";
                 }

                 $szReturnValue .= "</tr>\n";
             }

I think you want to put something like this:

             // loop and use key for titles
             foreach ($aRows[0] as $key => $value)
             {
                 if (strcasecmp($key, "SHAPE_INDEX") == 0 ||
                     strcasecmp($key, "TILE_INDEX") == 0 ||
                     strcasecmp($key, "LAYER_INDEX") == 0)
                     continue;
                 $szReturnValue .= "<td class=\"subContentArea2\"><p 
class=\"text\">".$key."</p></td>\n";
             }
             $szReturnValue .= "</tr>\n";

             // loop through the results and format each row
             foreach ( $aRows as $aRow )
             {
                 // add a row for each
                 $szReturnValue .= "<tr>\n";

                 // loop and add a cell for each result
                 foreach ( $aRow as $key => $xCell )
                 {
                     if (strcasecmp($key, "SHAPE_INDEX") == 0 ||
                         strcasecmp($key, "TILE_INDEX") == 0 ||
                         strcasecmp($key, "LAYER_INDEX") == 0)
                         continue;
                     $szReturnValue .= "<td class=\"subContentArea1\"><p 
class=\"text\">". $xCell."</p></td>\n";
                 }

                 $szReturnValue .= "</tr>\n";
             }

I just tried this and it seems to work.

Alternately you could invert the logic and restrict the query results to 
exactly what you do want ...

             // loop and use key for titles
             foreach ($aRows[0] as $key => $value)FID; Shape; Name; Detail
             {
                 if (strcasecmp($key, "FID") != 0 ||
                     strcasecmp($key, "Shape") != 0 ||
                     strcasecmp($key, "Name") != 0 ||
                     strcasecmp($key, "Detail") != 0)
                 {
                     $szReturnValue .= "<td class=\"subContentArea2\"><p 
class=\"text\">".$key."</p></td>\n";
                 }
             }
             $szReturnValue .= "</tr>\n";

             // loop through the results and format each row
             foreach ( $aRows as $aRow )
             {
                 // add a row for each
                 $szReturnValue .= "<tr>\n";

                 // loop and add a cell for each result
                 foreach ( $aRow as $key => $xCell )
                 {
                     if (strcasecmp($key, "FID") != 0 ||
                         strcasecmp($key, "Shape") != 0 ||
                         strcasecmp($key, "Name") != 0 ||
                         strcasecmp($key, "Detail") != 0)
                     {
                         $szReturnValue .= "<td 
class=\"subContentArea1\"><p class=\"text\">". $xCell."</p></td>\n";
                     }
                 }

                 $szReturnValue .= "</tr>\n";
             }

Cheers,

Paul

Tracy Howlett wrote:

>>Pardon the duplicate post - just wanted to make sure the subject heading
> 
> wasn't misleading!
> 
> Hello All, 
> 
> My application is pretty much finished now but I do have a couple of
tweaks
> I'd like to get done.
> 
> My query tool works well but in my query results I always get these three
> additional fields:
> 
> SHAPE_INDEX; TILE_INDEX; LAYER_INDEX
> 
> I'd like to suppress this information as it means nothing to the user.  In
> order to try and streamline my query results all of my shapefiles contain
> only the following fields:
> 
> FID; Shape; Name; Detail
> 
> I've dug around and I think that the table is being written out in the
> QueryResults.phtml file.  I see a number of arrays in there which I assume
> are populated with my layers and the fields for each layer.  Could someone
> give me some hint as to how I can tell the array to ignore the above named
> fields???  The part I can't figure out is how the names of the fields are
> being changed from FID in my shapefile to SHAPE_INDEX in the results.  Is
> there a file I'm missing which includes this name switch?
> 
> Any help would be appreciated.  I'm guessing that I'm not the only person
> who'd like to have these ID fields be invisible!
> 
> Cheers!
> 
> Tracy
> 
> 
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
> 
> 
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
> 

-- 
  -----------------------------------------------------------------
|Paul Spencer                           pspencer at dmsolutions.ca   |
|-----------------------------------------------------------------|
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
  -----------------------------------------------------------------

_______________________________________________
Chameleon mailing list
Chameleon at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/chameleon




More information about the Chameleon mailing list