使用 php SDK,我想获取登录页面的所有内容,这将包括具有不同内容类型/组件的部分,每个条目具有不同的字段。
例如。
第 1 节 - 英雄
第 2 节 - 文章
第 3 部分 - 图像
问:如何循环并获取链接的部分内容。
如果条目包含指向资产或其他条目的链接,SDK 将自动加载它。
我正在努力理解文档。我究竟如何打破这些价值观?
<?php
$query = new \Contentful\Delivery\Query();
$query->setContentType('page_landing')
->where("fields.urlHandle[match]", $slug);
$products = $client->getEntries($query);
foreach ($products as $product) {
echo $product['name'];
// Example of what I am trying to achieve
if($product['sections']['id']=='hero'){
$title= $product['sections']['hero']['title'];
}
if($product['sections']['id']=='article'){
$text = $product['sections']['article']['text'];
}
}
?>