Sorry, I gave you a bad example (I wasn't using phptal for some time), this one is better and simplier:

<div tal:repeat="field fieldnames">
${field/description}: <span tal:replace="person/${field/key}"></span>
</div>

W dniu 29.08.2012 16:12, Marco Pivetta pisze:
Use the ArrayAccess interface and implement your own iterator in your Person object, no?

http://php.net/manual/en/class.arrayaccess.php

Marco Pivetta

http://twitter.com/Ocramius

http://marco-pivetta.com



On 29 August 2012 15:39, GRolf <ger...@pictureparking.com <mailto:ger...@pictureparking.com>> wrote:




    Is it possible to use variable variables in PHPTal ?

    eg I have a PHP array
    $phptal->fieldnames = array(array('key'=>'first_name',
    'description'=>'First Name'), array('key'=>'address',
    'description=>'Address');

    and an object
    $person= new stdClass();
    $person->first_name = 'Joe';
    $person->address='His_street 1';
    $phptal->person = $person;

    and in my template I'd like to use the "key" of "fieldnames" in a
    repeat ...


    <div tal:repeat="field fieldnames">
    ${field/description}: ${person/${field/key}}
    </div>


    This doesn't work - but is there an other way to achieve it ?

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




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

--
Pozdrawiam
Piotr Kroczyński
_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to