[Cartoweb-users] Tooltips template

Oliver Christen oliver.christen at camptocamp.com
Tue May 15 08:39:53 EDT 2007


Hi Sylvain

from what you say, I guess you use Cartoweb 3.3, so you have this function:
    public function renderResult($smarty) {
        // Assigns a key => value attributes array to layerResults smarty
        // variable
        $smarty->assign('layerId', $this->getId());
        $smarty->assign('layerLabel',
            Encoder::encode($this->getLabel(), 'config'));

        $template = $this->getCustomTemplate();
        if ($template) {
            foreach ($this->returnedAttributes as $key => $value) {
                $smarty->assign($key, $value);
            }
            return $smarty->fetch($template);
        } else {
            $smarty->assign('layerResults', $this->returnedAttributes);
            return $smarty->fetch('layerResult.tpl');
        }
    }
}

if you add some debug:

        if ($template) {
            print 'template '.$template.' found<br>';
            foreach ($this->returnedAttributes as $key => $value) {
                print $key.' : '.$value.'<br>';
                $smarty->assign($key, $value);
            }
            $html = $smarty->fetch($template);
            print $html;
            return $html;
        }

what is the output?

also, you can add a printr in the template itself
{$layerResults|@print_r}

you must have the file modifier.print_r.php in 
cartoweb3\scripts\include_addons\include\smarty\plugins, if you dont have 
it, you can get if off Cartoweb cvs

this should give some light on whats happening

regards
Oliver


> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> I come again with my tooltips problems:
>
> In my tooltips.ini, i've got :
>
>   timeout_async.ecm_poly.template = "layerResult_poly.tpl"
>
> In the renderResult() function (LayerResult.php), i checked that
> $template contains the good value (layerResult_poly.tpl), and it does.
>
>        $template = $this->getCustomTemplate();
>
> But anyway, the layerResult_poly.tpl template is not apply at all.
>
> I tried to add some debug informations in the Smarty.class.php::fetch
> function. I can see the  layerResult_poly.tpl  as a parameter, but just
> after that, i see results.tpl coming. And in fact, if i change the
> results.tpl, i've got some change in my tooltips.
>
> Last thing, this is for example the content of results.tpl :
>
> {foreach key=attributeName item=attributeValue from=$layerResults}
>    <b>{t}{$attributeName|capitalize}{/t} : </b>
>        {if $attributeName=='numero'}
>           <font color='#00AA00'>{t}{$attributeValue}{/t}</font></a><br>
> {else}
>      {t}{$attributeValue}{/t}<br>
> {/if}
> {/foreach}
>
> But it does not do anything.
>
> Any ideas ?
>
> Thank you.
>
> Sylvain Beorchia.
> Makina Corpus
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFGSVrvit+Ro3cR7XYRAmVhAKC1PyEW/MmkEjJ2FfEFZOCNVb8KJACgqAdr
> y7C67PfSLDHDkbioMz7M8zw=
> =5y9+
> -----END PGP SIGNATURE-----
> 



More information about the Cartoweb-users mailing list