[Chameleon] moving widgets into custom directories
Paul Spencer
pspencer at dmsolutions.ca
Wed Jun 1 09:11:45 EDT 2005
Bart,
what we normally do in this case is have a configuration file that
defines where chameleon is.
define( "CHAMELEON_PATH", "/ms4w/apps/chameleon/htdocs" );
The popups need to use CHAMELEON_PATH to access stuff like
session.inc.php and other common code.
include( "../../config.php" );
include( CHAMELEON_PATH."/session.inc.php" );
you could make this fancier:
if (file_exists( "../../../config/config.php" ))
{
//include application configuration file if it exists
include( "../../../config/config.php" );
}
if (!is_defined( "CHAMELEON_PATH" ))
{
//assume chameleon at same level as application
define( "CHAMELEON_PATH", "../../../../chameleon/htdocs" );
}
In the widgets, you can then modify the moPopup->mszLink to be:
$this->moPopup->mszLink =
$_SESSION['gszAppWebPath']."/widgets/myWidget/myPopup.phtml";
the popup code will only put the chameleon stuff in front of the link
path if the path starts with ./widgets or widgets (see Popup.php
GetPopupURL() function)
This is essentially the same solution as Bill's except that it uses the
application web path calculated by Chameleon rather than doing it yourself.
Another solution may be to put all your widgets in a web-accessible
location for use by all your apps ... for instance
/ms4w/apps/chameleon
/ms4w/apps/customWidgets/widgets/...
/ms4w/apps/myApp
in your CWCExecute, you would pass the path to the custom widgets directory
in your widgets, they would have a configuration file that would define
both the CHAMELEON_PATH and CUSTOM_WIDGETS_URL
define ("CHAMELEON_PATH", "/ms4w/apps/chameleon/htdocs" );
define ("CUSTOM_WIDGETS_URL", "http://myserver/customwidgets");
$this->moPopup->mszLink = CUSTOM_WIDGETS_URL."/myWidget/myPopup.phtml";
If you use one of these solutions, can you please add something to the
chameleon tiki so we can point others there :)
HTH
Paul
William Bronsema wrote:
> Hi Bart,
>
> This is a messy type of situation. I'm not sure what Paul has in mind to
> address this, but here is what I have done in the past:
>
> define( 'GQUERY_WEBPATH', 'http://'.$_SERVER['HTTP_HOST'].
> dirname( $_SERVER['PHP_SELF'] ).'/' );
>
> I define this right in the widget itself and then just pre-pend this to
> whatever link I need.
>
> There is a way to detect https vs. http, but I can't recall what that is
> right now.
>
> HTH.
>
> Regards,
> Bill
>
>
> -----Original Message-----
> From: chameleon-bounces at lists.maptools.org
> [mailto:chameleon-bounces at lists.maptools.org] On Behalf Of Bart van den
> Eijnden
> Sent: Wednesday, June 01, 2005 5:58 AM
> To: chameleon at lists.maptools.org
> Subject: [Chameleon] moving widgets into custom directories
>
> Hi list,
>
> I am trying to move my self-made widgets into a custom directory. It works,
> but only the popups (phtml files) are not found.
>
> Is a widget aware of its web location? I guess not.
>
> Or do I need to write the (relative) path in the widget.php file myself?
>
> eg, now it says:
>
> $this->moPopup->mszLink =
> $_SESSION['gszCoreWebPath']."/widgets/WFSSearch/WFSSearch.phtml";
>
> I could change this into:
>
> $this->moPopup->mszLink =
> "/stragisweb/widgets/WFSSearch/WFSSearch.phtml";
>
> But I would rather have the widget determine its web location automagically
> ..... or from configuration .....
>
> Also, how does one deal with the includes for widget.php etc.? Those need to
> be adapted as well.
>
> include_once(dirname(__FILE__)."/../Widget.php");
>
> Is there a directive just like COMMON to use for the CHAMELEON root widget
> directory? That would come in handy.
>
> Any best practices?
>
> Best regards,
> Bart
>
> Bart van den Eijnden
> Syncera-ITSolutions
> Postbus 270
> 2600 AG DELFT
>
> tel.nr.: 015-7512436
> email: BEN at Syncera-ITSolutions.nl
>
>
> _______________________________________________
> 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/|
+-----------------------------------------------------------------+
More information about the Chameleon
mailing list