[Chameleon] Mixing PHP & Chameleon Widgets?

Liz Godwin godwin.liz at gmail.com
Fri May 20 08:43:44 EDT 2005


Hi BIll,
 I was going to reply straight off the bat and suggest that this cannot be 
done, because at one point, early in my Chameleon experience, I wanted to 
this... BUT I had a thought...
 I believe it IS possible to read in a template from a URL. Might be risky 
... but I think it's possible. If you read in a template in this way it is 
processed by the web server before passed along, which means PHP gets in 
there. You'd have to read in the template and save it as a file though I 
think. I have an example where I did this with a remote context document, 
but I havn't tried with remote templates. I'd like my templates to be 
predictable. 
 There also might be path issues I havn't thought of yet...
 All of this pointing and saving of a remote file would happen in the 
index.phtml file that calls chameleon.
 Sample:
//$szURL is a url of a context document in this case
if (isset($szURL)) {
$aszFile = file( $szURL );
$szContext = tempnam($_SESSION['gszTmpPath'], "context").".cml"; 
$fh = fopen($szContext, "w"); 
$nLines = count($aszFile); 
for($i=0; $i<$nLines; $i++) {
fwrite($fh, $aszFile[$i]);
}
fclose($fh);
}
 $oApp->moMapSession->oMap->loadMapContext( $szContext );
 Depending on what you want to build dynamically into your 
template...building a simple widget is actually not as bad as it might 
seem....

Cheers,
Liz Godwin

PS. Sorry if you get this twice Bill, I forgot to reply to the list as well.
 On 5/19/05, Bill Binko <bill at binko.net> wrote:
 
> Ok, I'm going to show my cluelessness here for a minute.
> 
> I'm looking to integrate map elements into pages that already include PHP
> code.
> 
> I understand the goal of separating the markup and the logic, but I would
> like to embed widgets in pages that are dynamically created, and the
> systems they work with don't have a Tag-based abstraction layer.
> 
> Is there a way to do this? Is there a way to setup Chameleon so that
> after it has done it's processing it feeds the results back into PHP to
> execute? Or perhaps the opposite (PHP first, then Chameleon)? I think I
> can manage with either of those solutions.
> 
> If not, I will have to encapsulate all of that existing logic into
> Chameleon widgets (and I'm not sure I can consolidate it as well as I'd
> need to. That is, I'd have many widgets that had to cooperate.
> 
> Any pointers for a newbie would be appreciated.
> 
> Bill
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/chameleon/attachments/20050520/e8bd8d0b/attachment.html


More information about the Chameleon mailing list