[Cartoweb-users] pdf plugins : block with db content

Oliver Christen oliver.christen at camptocamp.com
Fri Nov 2 06:09:15 EDT 2007


Hi

as far as I know, there is no built-in mechanism to genericaly pass a 
variable value to a block.
so you will need to extend the exportPdf and add some specific case to 
handle you block.

this is only an easy hack but it seems to work, im sure there are other way 
to do it
1) in the exportPdf.ini, write the connection string with %s where you want 
to write the condition values
blocks.copyright.content = "db~pgsql://xxx:yyy@zzz.com/demo_plugins~select 
name from people where id = %s"

2) extend the exportPdf plugin(see doc 
(http://www.cartoweb.org/doc/cw3.4/xhtml/dev.newplugin.html#dev.newplugin.adapting.extending) 
you can also directly modify the ClientExportPdf.php but thats not very 
clean)
and override the createBlock function.
all you have to do is copy the function content and simply slightly modify 
the lines where you have
        if ($this->blocks[$id]->type == 'text' &&
            (stristr($this->blocks[$id]->content, 'file~') ||
             stristr($this->blocks[$id]->content, 'db~'))) {

simply add something like this
            if ($id == 'your_block_name') {
                $this->blocks[$id]->content = 
sprintf($this->blocks[$id]->content, $your_value);
            }

now all you have to do is to get the $your_value but you should be able to 
recover it from handleHttpPostRequest or from session.

regards
Oliver


> Hi All,
>
> Don't know if someone is using it
>
> I've been ask to print in pdf a result of a query.
>
> As it was indicate in documentation we can make a
> blocks.myText.content = "db~pgsql://user:password@localhost/dbname~select 
> column from table where x=(some value) AND y=(some
> other value);
>
> What I need to know is how can I have dynamic value for the x= et y= ?
> Typically how to give the x,y top left  and the x,y bottom right 
> coordinate of the pdf.
>
> Any clue, help or more information are welcome ...
>
> -- 
>
>     Bruno Friedmann  bruno at ioda-net.ch
>
> Ioda-Net Sàrl   - www.ioda-net.ch
>  2830 Vellerat - Switzerland
>
>
>
> _______________________________________________
> 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