[Cartoweb-users] Generate dinamically template file

Fabio D'Ovidio fabiodovidio at gmail.com
Wed Mar 26 06:23:24 EDT 2008

 From my own plugin I want to generate dinamically .tpl file after 
querying a table in the database linked to auth plugin trought
dbSecurityDsn = pgsql://......
dbSecurityQueryUser = "SELECT * FROM operatori WHERE op_login='%s' AND 
dbSecurityQueryRoles = "SELECT cast(id_operatore AS text) FROM operatori 
WHERE op_login='%s'"

and fill combo values in the template. How can i do it?
I've tried as following:

My_plugin.tpl file:
<fieldset><legend>{t}Scegli il Comune{/t}</legend>

<select name="exampleRecenterField">
<option value=''>Seleziona...
<option value = "{$value}">{$value}

<!-- <input  value="Vai" type="submit"/> -->
<a href="javascript:doSubmit();"><img src="{r 
type=gfx/layout}xy.gif{/r}" id="refresh_recenter" alt="{t}Recenter{/t}" 



protected function drawAuth() {

        $smarty = new Smarty_Plugin($this->getCartoclient(), $this);
        $anonymous = SecurityManager::getInstance()->hasRole(
        $smarty->assign('show_login', $anonymous);
        $smarty->assign('show_logout', !$anonymous);
        // My code STARTS

         $sm = SecurityManager::getInstance();
          $Role = $sm->getRoles();
          $hasRoleMyrole = $sm->hasRole($Role[2]);
        $filename = "$Role[2].tpl";
        $dsn = $this->getConfig()->dbSecurityDsn;
        $db = Utils::getDb($db, $dsn);
        $sql = "select operatori.id_affiliato, affiliati.id_affiliato, 
affiliati.comune_az from operatori, affiliati where 
affiliati.id_affiliato = operatori.id_affiliato and 
        $res = $db->query($sql);
        $row =& $res->fetchRow(DB_FETCHMODE_OBJECT);
        $value = $row->comune_az;
        //print_r($Role[2]." ");
        //echo $smarty->get_template_vars('value');
        $smarty->assign('value', $value);
        //echo $smarty->get_template_vars('value');

 // END
        return $smarty->fetch('auth.tpl');

Ing. Fabio D'Ovidio

iQuadro - Informatica e Innovazione s.r.l.
Via C. Pisacane 23, Aversa (CE) - 81031
Web : www.ii2.it
Tel.: 081 197 57 600
mail: fabiodovidio at gmail.com

More information about the Cartoweb-users mailing list