[Cartoweb-users] Generate dinamically template file

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


Hi!
 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 
op_password='%s'"
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:
<center>
<fieldset><legend>{t}Scegli il Comune{/t}</legend>
<div><b>


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

&nbsp;&nbsp;&nbsp;
<!-- <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}" 
title="{t}Recenter{/t}"></img></a>



</b></div>


</center>


ClientAuth.php
protected function drawAuth() {

        $smarty = new Smarty_Plugin($this->getCartoclient(), $this);
        $anonymous = SecurityManager::getInstance()->hasRole(
                                            
SecurityManager::ANONYMOUS_ROLE);
        $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 
operatori.id_operatore=$Role[2]";
        $res = $db->query($sql);
        Utils::checkDbError($res);
        $row =& $res->fetchRow(DB_FETCHMODE_OBJECT);
        $value = $row->comune_az;
        //print_r($Role[2]." ");
        //print_r($value);
       
      
        
$smarty->fetch('C:/ms4w/apps/cartoweb3/projects/k21/plugins/exampleRecentering/templates/recenter.tpl');
        $smarty->get_template_vars('value');
        //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