php - How to handle Multidimensional Array on XML Template?
Get the solution ↓↓↓Solution:
You should git this array a name. Just rewrite$app->render
part this way:
return $app->render('chkdb.xml', ['photos' => $oArray]);
And write in template:
{% for x in photos %}
Answer
Solution:
Oh man... my bad.. I found the answer to this... There is nothing wrong on my Template.. it's my bad not naming the Array I send.. Here's the corrected code..
$app->post(
'/get_gallery_allphotos',
function () use ($app) {
require_once 'lib/mysql.php';
$re = getAll_photos('MyPhotos');
$app->response->setStatus(200);
$app->response()->headers->set('Content-Type', 'text/xml');
return $app->render('myphotos_allphotos_admin.xml', array("ArrayName" => $re));
}
);
I forgot to name the Array i send... So here i put ArrayName as the name of the $re...
So in the template i use the..
{% for x in ArrayName %}
<MyPhotos>
<ObjID>{{x.ObjID}}</ObjID>
<ParenetID>{{x.ParenetID}}</ParenetID>
<Path>{{x.Path}}</Path>
<Title>{{x.Title}}</Title>
<ChildCount>{{x.ChildCount}}</ChildCount>
<Owner>{{x.Owner}}</Owner>
<Comment>{{x.Comment}}</Comment>
<inode>{{x.inode}}</inode>
</MyPhotos>
{% else %}
Not Found
{% endfor %}
Hope it helps somebody else ^^,
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to a member function store() on null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.