You are here

function opigno_forum_app_opigno_breadcrumbs in Opigno Forum App 7

Implements hook_opigno_breadcrumbs().

File

./opigno_forum_app.module, line 15
Module file. Defines module hooks.

Code

function opigno_forum_app_opigno_breadcrumbs($gid) {
  $breadcrumbs = array();
  $node = menu_get_object();

  // Must we handle this page request for the breadcrumb ?
  if (isset($node->type) && $node->type == 'forum' || preg_match('/^comment\\/reply\\/[0-9]+/', current_path())) {

    // Add the Forums link.
    $forum_id = opigno_forum_app_get_course_forum_id($gid);
    $breadcrumbs[] = l(t("Forum"), "forum/{$forum_id}");

    // If we're replying, add the topic link as well.
    if (preg_match('/^comment\\/reply\\/[0-9]+/', current_path())) {
      $parts = explode('/', current_path());

      // Replying to a comment ? Remove comment ID.
      if (preg_match('/^comment\\/reply\\/[0-9]+\\/[0-9]+/', current_path())) {
        array_pop($parts);
      }
      $topic_id = array_pop($parts);
      $topic = node_load($topic_id);
      $breadcrumbs[] = l($topic->title, "node/{$topic_id}");
    }
  }
  if (!empty($breadcrumbs)) {
    return $breadcrumbs;
  }
}