Hello
I have a next post.php file
<?php
$cat = $this->param(‘cat’);
$post = $this->param(‘post’);
if (!$cat || !$post) {
echo “Not found post or cat params…”;
return “Not found post or cat params…”;
}
$entries = cockpit(‘collections’)->find(‘post’, [
‘filter’ => function($document) use ($cat, $post) {
if ($document[‘url’] === $post){
foreach((array)$document[‘category’] as $item) {
if ($item[‘display’] === $cat) return true;
}
}
return false;
}
]);
$populated_entries = cockpit('collections')->populate('post', $entries)->toArray();
echo "<script>console.log(".json_encode($populated_entries).")</script>";
return $entries;
It is used to find all post by postUrl and catUrl. (Post can have more categories)
In $entries
I have all post by postUrl and catUrl. (Post can have more categories);
Now I need to “expand” all collection Links (populate). I try to do it and save results to $populated_entries variable. But it doesn;t work
What do I wrong?
Thanks