[Cartoweb-users] Retrieving a Smarty Variable from
cartoclient.tpland writing its contents to a html file
Oliver Christen
oliver.christen at camptocamp.com
Mon Nov 13 03:05:24 EST 2006
Why dont you extend the table plugin ? So you could act directly where the
table_result is generated and you could have better control on the php code
than inside a smarty template.
to extend a plugin, you simply have to create a new php file, named for
exemple ClientMyProjectTables.php and containing:
<?php
/**
* @package CorePlugins
* @version $Id: ClientMyProjectTables.php,v 1.8 2005/02/23 11:52:43 johndoe
Exp $
*/
class ClientMyProjectTables extends ClientTables {
public function replacePlugin() {
return 'tables';
}
/* Add or overload methods here */
}
?>to know where to add your piece of code writing your messagem.html file,
refer to the flow diagram
(http://www.cartoweb.org/doc/misc/plugins_diagram.pdf (yes the quality is
low, I need to redo it))If you want to have exactly the same result object
as in the normal table output, you will have to do it in function renderForm
or after, like this: public function renderForm(Smarty $template)
{ $tablesResult = $this->renderFormPrepare(); $file =
fopen("messagem.html","w"); // maybe you will have to check the path to this
file $tag1= "<html><head><title></title></head><body>";
$tag2="</body></html>"; fwrite($file,$tag1); fwrite($file,
$tablesResult); fwrite($file, $tag2); fclose($file);
parent::renderForm($template); }
> Hi,
>
> Because of my lack of knowledge about how Smarty
> works, I've been unable to solve this issue: I'm
> trying to retrieve the values of a Smarty variable
> into a {php} {/php} section, located inside the
> ./projects/MyProject/templates/cartoclient.tpl .
>
> The problem is simple, I wish to have the
> query_by_bbox results to be written inside a html
> file. I have realised that those results are stored
> inside the cartoclient.tpl Smarty variable,
> $tables_result. So, I've developed this simple piece
> of php code:
>
> {php}
> $tablesResult = $tables_result;
> $file = fopen("messagem.html","w");
> $tag1= "<html><head><title></title></head><body>";
> $tag2="</body></html>";
> fwrite($file,$tag1);
> fwrite($file, $tablesResult);
> fwrite($file, $tag2);
> fclose($file);
> {/php}
>
> But it generates a blank html file (messagem.html).
> What is wrong with this piece of code? Is it possible
> to have this working that way (inside the
> cartoclient.tpl file)?
>
> Thanks in advance,
>
> Max H. Ueda
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> _______________________________________________
> Cartoweb-users mailing list
> Cartoweb-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/cartoweb-users
>
More information about the Cartoweb-users
mailing list