Forum
perch runway collection array echo error
Pulling a collection item with ajax based on url, works fine using an html template and perch_content tags but want to spit out the variables and echo out so when skip-template used array seems to have structure and content and can be seen in a print_r display but can't get to content using this kind of call -
$thetitle = $articleContent[0]['Title'];
Getting error - Notice: Undefined offset: 1 in ......
print_r returns array data -
Array ( [0] => Array ( [_id] => 5 [Title] => Physiotherapy [_title] => Physiotherapy [subhead] => Diagnosing, treating and rehabilitating injuries. [slug] => physiotherapy [page-image] => /site-admin/resources/physiotherapy-3.jpg [alt] => Patient receiving treatment [TextLeft] =>........
and so on....
$articleContent = perch_collection($parentTitle, [
'filter' => 'slug',
'match' => 'eq',
'value' => perch_get('article'),
'skip-template' => true,
'return-html' => false,
]);
print_r ($articleContent);
if (!empty($articleContent)) {
//set content vars
$thetitle = $articleContent[0]['Title'];
//test vars
echo $thetitle;
}
I have similar code working fine with perch_content_custom, getting array and echoing out the variables but can't get it to work with perch_collection
Any advice appreciated.
Thanks
In...? You left out the most important bit! :)
Ah sorry Drew
So to clarify my print_r displays the array fine -
As soon as I add
I get errors like the one above.
Hope that helps and thanks.
keith
Drew I now have it working, odd as I'm not sure why it is now when it wasn't earlier.
Thanks again anyway. K
Ok, great