You are here

function breadcrumb_display in Views breadcrumb 7

Return value

array|null breadcrumb link

1 call to breadcrumb_display()
views_breadcrumb_block_view in ./views_breadcrumb.module
Implements hook_block_view().

File

./views_breadcrumb.module, line 39
This module will provide a block that will helps to set the bread crumb for views pages.

Code

function breadcrumb_display() {
  global $base_url;
  $count = 0;
  $path = current_path();
  $access = db_query("SELECT m.access_callback  FROM {menu_router} m WHERE m.path LIKE :path AND  m.page_callback LIKE :views_page", array(
    ':path' => $path,
    ':views_page' => 'views_page',
  ))
    ->fetchField();
  if (empty($access)) {
    $output = drupal_set_message(t('Views breadcrumb block module only for views pages, please <a href="@url">configure</a> correctly.', array(
      '@url' => url('admin/structure/block/manage/views_breadcrumb/views_breadcrumb_block/configure'),
    )));
  }
  else {
    $plid = db_query("SELECT ml.plid  FROM {menu_links} ml WHERE ml.link_path LIKE :path", array(
      ':path' => $path,
    ))
      ->fetchField();
    for ($i = 0; $plid > -1; $i++) {
      if ($plid == 0) {
        $plid = -1;
      }
      else {
        $result = db_query("SELECT ml.plid, ml.link_path, ml.link_title FROM  {menu_links} ml WHERE mlid = :plid", array(
          ':plid' => $plid,
        ));
        foreach ($result as $value) {
          $plid = $value->plid;
          $data[$i]['link_path'] = $value->link_path;
          $data[$i]['link_title'] = $value->link_title;
          $count++;
        }
      }
    }
    $breadcrumb[] = l(t('Home'), $base_url);
    for ($j = $count - 1; $j > -1; $j--) {
      $breadcrumb[] .= l($data[$j]['link_title'], $data[$j]['link_path']);
    }
    $breadcrumb[] .= l(drupal_get_title(), $base_url . '/' . $path);
    $output = drupal_set_breadcrumb($breadcrumb);
  }
  return $output;
}