You are here

protected function crumbs_CurrentPageInfo::jsonLdData in Crumbs, the Breadcrumbs suite 7.2

@link http://schema.org/BreadcrumbList

Return value

array

See also

$jsonLdData

File

lib/CurrentPageInfo.php, line 346

Class

crumbs_CurrentPageInfo
Creates various data related to the current page.

Code

protected function jsonLdData() {
  $i = 0;
  $dataListItems = array();
  foreach ($this->metaBreadcrumbItems as $item) {
    $dataListItem = array(
      '@type' => 'ListItem',
      'position' => ++$i,
      'item' => array(
        'name' => check_plain($item['title']),
      ),
    );
    if ('<nolink>' === $item['href']) {

      // Nothing.
    }
    else {
      $link_options = isset($item['localized_options']) ? $item['localized_options'] : array();
      $link_options['absolute'] = TRUE;
      $dataListItem['item']['@id'] = url($item['link_path'], $link_options);
    }
    $dataListItems[] = $dataListItem;
  }
  if (empty($dataListItems)) {
    return array();
  }
  return array(
    '@context' => 'http://schema.org',
    '@type' => 'BreadcrumbList',
    'itemListElement' => $dataListItems,
  );
}