[Chameleon] Template/widget questions (Visible=false?)

Paul Spencer pspencer at dmsolutions.ca
Mon Nov 1 20:06:50 EST 2004


Mike,

the template preprocessor was probably discussed on the mailing list but 
it would have been hard to find unless you knew what you were looking for.

All this will end up in the documentation that is currently being written :)

Current CVS is very close to what will be released as 1.99 beta 3. 
There are only a couple of minor issues to verify then we will be 
cutting the new version and going on to fix bugs for RC1.

Cheers,

Paul

Mike Leahy wrote:
> Paul,
> 
> Thanks - your reply is really helpful, and gives me some good ideas.  Is this 
> info included in any documentation that I have overlooked?  I'm thinking I 
> should get the CVS as well, since these fixes and widgets such as MapTitle 
> aren't in the current download (unless it has been changed in the past week or 
> two).
> 
> Kind regards,
> Mike
> 
> 
> 
> -----Original Message-----
> From: Paul Spencer [mailto:pagameba at magma.ca] 
> Sent: October 29, 2004 10:37 AM
> To: Mike Leahy
> Cc: chameleon at lists.maptools.org
> Subject: Re: [Chameleon] Template/widget questions (Visible=false?)
> 
> Mike, comments inline ...
> 
> Mike Leahy wrote:
> 
>>Hello list,
>>
>>I'm just getting started using one of the chameleon samples to try building 
> 
> my 
> 
>>own template.  My first question is whether there is anyone who can imagine 
>>how I might be able to dynamically change the content of a template prior to 
>>its use by chameleon.  
> 
> 
> there are two template pre-processors that can be used to dynamically 
> change a template's content:
> 
> 1. [$<variable>[|<default>]$]
> 
> This preprocessor directive replaces the [$ ... $] tag with the value of 
> <variable> or <default> if <variable> is not defined.  <variable> is the 
> name of a GET or POST variable.  <default> is any text string and is 
> optional.  If you do not include a | then if the <variable> is not 
> found, it is not replaced and you will end up with [$<variable>$] in 
> your template.  You can specify an empty string using [$<variable>|$]. 
> Some examples:
> 
> url1:  http://<myserver>/myapp/myapp.phtml?mytitle=This+Is+My+Title
> url2: http://<myserver>/myapp/myapp.phtml?mytitle=This+Is+My+Title
> 
> template:
> 
> [$mytitle|No title?$]
> 
> output for url1:
> This Is My Title
> 
> output for url2:
> No title?
> 
> Another template:
> [$mytitle$]
> 
> output for url1:
> This Is My Title
> 
> output for url2:
> [$mytitle$]
> 
> 2. [#<filename#]
> 
> This preprocessor directive "includes" the contents of <filename> in the 
> template in place of itself.  You could use this to manage sets of style 
> resources, widgets, help text, anything.
> 
> The code (in TemplateParser.php) processes [# #] first, and then [$ $]
> 
> An simple example of what I mean would be the map
> 
>>title...in the samples, the text for the map title is set in a "title" 
>>widget.  If i use the same template to display a different mapfile, however, 
>>the title should appropriately change.  Similarly, I may want to change the 
>>content of other labels, and include/exclude or enable/disable various 
> 
> widgets 
> 
>>depending on the current map or user context.  Should I be considering 
>>developing my own widgets from scratch or by modifying those distributed 
> 
> with 
> 
>>Chameleon?  (a side note: I found that replacing '$szLabel = ""' 
>>with '$szLabel = $this->mszLabel;' to the beginning of the DrawPublish 
>>function of the CWCLabel class made the NAME property of a mapfile the 
> 
> default 
> 
>>value for the Title widget).  
>>
> 
> 
> There is a MapTitle widget that you could use ;)  In most cases, it is 
> possible to change the labels through the widget tag or to eliminate the 
> labels and use your own in the template.  For instance:
> 
> <cwc2 type="ProjectionLabel" label="Projection:" labelclass="label" 
> widgetclass="inputBox"/>
> 
> you can change label="" to your own string, or leave it out and put:
> 
> <span class="myLabel">Proj:</span><cwc2 type="ProjectionLabel" 
> widgetclass="inputBox"/>
> 
> If you find that some widget is not flexible enough, please report it as 
> I am trying to make all widgets work in roughly the same way, and this 
> includes making it highly flexible.
> 
> A note on the labels.  It is highly likely that I will be removing 
> support for this type of in-widget labelling (first example) as it is 
> much easier and more flexible to simply edit the template and add you 
> own.  It will also reduce code complexity and execution time (a small 
> amount).  This type of labelling is a hang-over from an earlier version 
> and has become largely unnecessary but I haven't had time to take it out 
> yet.
> 
> 
>>Another issue I'm wondering about is related to my attempt modify one of the 
>>chameleon samples to remove some of the widgets that I don't plan to use in 
> 
> my 
> 
>>application.  Deleting them doesn't seem to cause problems, but I thought I 
>>might try leaving some in and just setting the visible property of the 
> 
> widget 
> 
>>to "false", for example:
>>
>><cwc2 type="BoundingBoxPopup" image="icons/icon_zoombounds.png" 
>>visible="false" styleresource="NavButtons" popupstyleresource="TextButtons" 
>>imagetip="Zoom to Bounding Box or Point" imagewidth="24" imageheight="24" 
>>popupwidth="490" popupheight="450" toolbar="false" status="false" 
>>menubar="false">
>>  <image state="normal"/>
>>  <image state="selected"/>
>>  <image state="hover"/>
>></cwc2>
>>
>>When I did this, however, I got an alert message saying "image object for 
>>cwcimage_16 not found?".  I'm not sure what's causing this, since when I 
>>delete the same widget from the template I get no error at all.  Any ideas 
>>what might cause this?
> 
> 
> In preparing for releasing 1.99, one of the bugs that we fixed was the 
> ENABLED attribute.  With the latest CVS version, you can now set 
> ENABLED="false" and it will effectively disable the widget in the template.
> 
> Support for VISIBLE="false" should also be there, but I can't remember 
> if that bug has been fully addressed yet.  It is more complicated 
> because VISIBLE="false" implies that the widget is still in the 
> interface and functional, but it's user interface is missing.  This 
> means that the javascript functions and form variables that the widget 
> uses are in the page, but there is no visible interface.  The purpose of 
> this is obscure, but theoretically it should allow you to build your own 
> javascript/dhtml interface and use the javascript API of the widgets. 
> I'm not sure that it is actually practical to do this, however.
> 
> 
>>Thanks in advance for any comments,
> 
> 
> you are welcome :)
> 
> 
>>Mike
>>
>>----------------------------------------
>>This mail sent through www.mywaterloo.ca
>>_______________________________________________
>>Chameleon mailing list
>>Chameleon at lists.maptools.org
>>http://lists.maptools.org/mailman/listinfo/chameleon
>>
> 
> Cheers
> 
> Paul


More information about the Chameleon mailing list