Kornel Lesiński <kor...@...> writes:

> 
> 
> On 10.06.2009, at 23:57, hosema...@... wrote:
> 
> > Hi how to get $tpl->vars to include them for ex. into array and than  
> > execue inside template?
> > Ex.
> > I have defined:
> > $tpl = new PHPTAL('tpl/header.tpl');
> > $tpl->title = 'Panel administracyjny';
> > $tpl->manage = 'manage';
> > $tpl->settings = 'settings';
> > echo "echo translation".$tpl->manage;
> > $options = array(
> > array($tpl->manage,'parking.png','parking.php'),
> > array($tpl->settings,'settings.png','settings.php'),
> > array('sdfsdfs','camera.png','camera.php'));
> > echo $tpl->execute();
> > and when $tpl->manage is echoed there is null. I want some value  
> > ('manage');
> > the goal is to input variables into array and that pass array into  
> > template
> 
> I think reading of variables from template engine unnecessarily ties  
> the application to the template engine. You should use your own data  
> structures and only set them in PHPTAL object when displaying template:
> 
> $data = array();
> $data['manage'] = 'manage';
> $options = array($data['manage'],…)
> …
> foreach($data as $key => $value) $phptal->$key = $value;
> 


I have created automatic translation system. And from the point of view of 
class that inherit translated words there is problem with loops inside template 
that they have to be inside of array.
I have some function like
$lang->load('admin_panel',$tpl); $tpl is pass through reference and all 
translation is inside $tpl. The problem is with structure of data.
I have temporary solution that $translation_obj contains all translated word as 
object(and is accesible, $tpl is not).
$translation_obj = $lang->load('admin_panel',$tpl);
 But that would be faster and more coniniet to have possiblity to access $tpl 
directly like
echo $tpl->manage
or echo $tpl->get('manage');


_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to