Chameleon    Home  |  Docs  |  Support  |  Bugs  |  CVS  |  Downloads 

MapTools.org

How to Customize Any Widget

One of the questions that is often asked is how to customize popups in widgets. It would be nice if there was an easy way to do this, but right now there isn't. This describes a way of creating a copy of a chameleon widget so that it can be customized.

You will need a new directory to hold your custom widgets. This directory can be anywhere, including inside the Chameleon directory, but I am going to assume that it is inside your application's web accessible folder so that access to popups etc will work correctly.

Assuming you have the following directory structure:

<app>/htdocs

create a 'wdigets' directory inside htdocs:

<app>/htdocs/widgets

Copy the widget folder from chameleon/htdocs/widgets to this new folder. For instance, if you are copying the Query widget, you will end up with:

<app>/htdocs/widgets/Query/Query.widget.php

<app>/htdocs/widgets/Query/QueryResults.phtml

You will need to edit the widget files and change any lines that set $this->moPopup->mszLink to be the correct URL for your custom widgets. For instance, you could do the following in your custom Query.widget.php file:

$this->moPopup->mszLink=$_SESSION['gszAppWebPath']."/widgets/Query/QueryResults.phtml";

the way this works is that Popup.php will only use gszCoreWebPath (the web path to Chameleon) if $this->moPopup->mszLink starts with 'widgets' or './widgets' ... otherwise it will leave the link alone, assuming you have set the right thing.

You will need to tell Chameleon to use your custom widget instead of its version by adding the path to your widgets directory in the call to CWCExecute, as follows:

$oApp->CWCExecute( array( dirname(FILE)."/widgets" );

this will tell chameleon to search a widgets directory in your application first.

You may run into other problems with specific widget files but I think most of them use relative paths so it shouldn't be too bad.

If you try this and have any feedback for specific widgets, please either file a bug or post on the list so I can look at making the specific widget generic enough to make this work.

Created by: pspencer last modification: Thursday 12 of May, 2005 [14:32:21 UTC] by pspencer

Printer Friendly

 
 

Contact Information

Chameleon Users List