[Cartoweb-users] Using the selected object in the layer in my own plugin

Alexandre Saunier alexandre.saunier at camptocamp.com
Mon Oct 10 13:51:24 EDT 2005


Eduard Witteveen wrote:
 > I am curious how stable is the version in CVS?

There should be no problem using CVS version in production. Most 
Camptocamp projects use the latest CVS version. Changes are generally 
seriouly tested before being commited to the CVS server (unit tests, 
reviewed patches...) but a mistake is still possible. Note that a 
release is being prepared.

 > And when i use the version from cvs, what would be the code to call this
 > getTableGroups() method(from your story i suspect that extending is not
 > nessecary over there? and (maybe i like this more) can it also be used
 > in CW3.0 by adding a getTableGroups() method?)

With the CVS version you may actually get table groups in other plugins 
by using:
No need to extend anything.
If you prefer using CW3.0, just extend the tables plugin, add that 
getTableGroups() method and call it like this:

>> Good to point it out, i already know the mechanism. A little sidenote, 
>> would it be possible to make the errormessage clearer when this 
>> view.xml.tlp wasnt found? (with a path)
> I made the following modifications to the include\smarty\Smarty.class.php
> Line 1584:
> --                  $this->trigger_error('unable to read resource: "' . 
> $params['resource_name'] . '"');
> ++                if($_params['resource_type'] == "file") {
> ++                    $this->trigger_error('unable to read file: "' . 
> $params['resource_name'] . '" include:"' . get_include_path() . '" 
> working dir:"' . getcwd() . '"');
> ++                }
> ++                else {
> ++                    $this->trigger_error('unable to read resource: "' 
> . $params['resource_name'] . '" type:"' . $_params['resource_type'] . '"');
> ++                }

That's indeed an improvement but I guess you'd better submit the change 
directly to the Smarty team. We could overload Smarty's 
_fetch_resource_info() method in CW3 class Smarty_Cartoclient but I'm 
afraid the piece of code to override is quite too long.

>    public function renderForm(Smarty $template) {
>        // render parent!
>        parent::renderForm($template);
>        $smarty = new Smarty_CorePlugin($this->getCartoclient(), 
> $this);        // also tried to use template directly and constructor 
> Smarty()
>        $xml = $this->administrativeXml($this->tableGroups);
>        $smarty->assign('foo', 'bar');
>        return $smarty->fetch('foo.tpl');
>    }
> And i placed this file in 
> C:\cartoweb3\projects\%projectname%\plugins\foo\client\ClientFoo.php, 
> why doesnt the fetch('foo.tpl'); try to load the tpl from the location: 
> C:\cartoweb3\projects\%projectname%\plugins\foo\templates\foo.tpl
> How can i make my class aware of the file foo.tpl in my template folder?

Your template call seems correct as well as the file location. But at 
least I see that you do not use/store/return the 
parent::renderForm($template) result. It acts like if you'd never called it.

By the way: class Smarty_CorePlugin was renamed to Smarty_Plugin in CVS 
version since it is not reserved only to coreplugins.


More information about the Cartoweb-users mailing list