I can't convert my custom pages until i know how to access and loop with templates again. It is nice to know how to access one single var or single var in an array but how to loop? I did try my luck with ... (but without any success, yet ...)
Template i need to loop for output
PHP Code:
$namelist = vB_Template::create('names_loop')->render();
And the template that should display the whole looped conteend
PHP Code:
$templater = vB_Template::create('NAMES');
$templater->register('names', $data);
$templater->register('names_loop', $namelist);
print_output($templater->render());
$data is an array like
PHP Code:
$data = array(0 => array('name' => 'testuser', 'age' => 100), 1 => array('name' => 'testuser 2', 'age' => 99));
My "NAMES" template looks like this ...
Code:
<div>{vb:raw names_loop}</div>
My "names_loop" template looks like this ...
Code:
<div style="magin: 10px; padding: 10px;">
<div>{vb:raw names.name}</div>
<div>{vb:raw names.age}</div>
</div>
So far i can access all the vars in my array with {vb:var names.0.name} or {vb:var names.0.age} but i can't use it in templates to loop an output.
Can anyone help, please?
Thanks.