diff --git a/includes/menu.inc b/includes/menu.inc index 74694c8e026d4bbdb5c34bd74a408bf3bef28664..ac835c24340beb7b16a1c20b31100ee573da487f 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -267,17 +267,46 @@ function menu_unserialize($data, $map) { } } + + /** - * Get the menu callback for the a path. + * Replaces the statically cached item for a given path. * * @param $path - * A path, or NULL for the current path + * The path. + * @param $router_item + * The router item. Usually you take a router entry from menu_get_item and + * set it back either modified or to a different path. This lets you modify the + * navigation block, the page title, the breadcrumb and the page help in one + * call. */ -function menu_get_item($path = NULL) { +function menu_set_item($path, $router_item) { + menu_get_item($path, $router_item); +} + +/** + * Get a router item. + * + * @param $path + * The path, for example node/5. The function will find the corresponding + * node/% item and return that. + * @param $router_item + * Internal use only. + * @return + * The router item, an associate array corresponding to one row in the + * menu_router table. The value of key map holds the loaded objects. The + * value of key access is TRUE if the current user can access this page. + * The values for key title, page_arguments, access_arguments will be + * filled in based on the database values and the objects loaded. + */ +function menu_get_item($path = NULL, $router_item = NULL) { static $router_items; if (!isset($path)) { $path = $_GET['q']; } + if (isset($router_item)) { + $router_items[$path] = $router_item; + } if (!isset($router_items[$path])) { $original_map = arg(NULL, $path); $parts = array_slice($original_map, 0, MENU_MAX_PARTS); @@ -1385,9 +1414,6 @@ function menu_get_active_trail() { return menu_set_active_trail(); } -function menu_set_location() { -} - /** * Get the breadcrumb for the current page, as determined by the active trail. */ diff --git a/modules/blog/blog.module b/modules/blog/blog.module index e43a804356ebfcfc9dedb653369d7be0f553cecd..564261177fe4d075376353bf9ad435e259d6e70d 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -107,10 +107,7 @@ function blog_form(&$node) { function blog_view($node, $teaser = FALSE, $page = FALSE) { if ($page) { // Breadcrumb navigation - $breadcrumb[] = array('path' => 'blog', 'title' => t('Blogs')); - $breadcrumb[] = array('path' => 'blog/'. $node->uid, 'title' => t("@name's blog", array('@name' => $node->name))); - $breadcrumb[] = array('path' => 'node/'. $node->nid); - menu_set_location($breadcrumb); + drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Blogs'), 'blog'), l(t("@name's blog", array('@name' => $node->name)), 'blog/'. $node->uid))); } return node_prepare($node, $teaser); } diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 86b874130345a0b2f36fa7561638177067e8cfdf..877be28ae6659a6a69f4d87aba0e2f1f41560c95 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -681,8 +681,7 @@ function comment_edit($cid) { */ function comment_reply($node, $pid = NULL) { // Set the breadcrumb trail. - menu_set_location(array(array('path' => "node/$node->nid", 'title' => $node->title), array('path' => "comment/reply/$node->nid"))); - + drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->title, 'node/'. $node->nid))); $op = isset($_POST['op']) ? $_POST['op'] : ''; $output = ''; diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 600ae5a4678b999b7c5b399a676ea7756c44f6e6..e7b3bb683a557e9bfcbacc8c189a632d27e5fba4 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -184,16 +184,15 @@ function forum_nodeapi(&$node, $op, $teaser, $page) { } } // Breadcrumb navigation - $breadcrumb = array(); - $breadcrumb[] = array('path' => 'forum', 'title' => $vocabulary->name); + $breadcrumb[] = l(t('Home'), NULL); + $breadcrumb[] = l($vocabulary->name, 'forum'); if ($parents = taxonomy_get_parents_all($node->tid)) { $parents = array_reverse($parents); foreach ($parents as $p) { - $breadcrumb[] = array('path' => 'forum/'. $p->tid, 'title' => $p->name); + $breadcrumb[] = l($p->name, 'forum/'.$p->tid); } } - $breadcrumb[] = array('path' => 'node/'. $node->nid); - menu_set_location($breadcrumb); + drupal_set_breadcrumb($breadcrumb); if (!$teaser) { $node->content['forum_navigation'] = array( @@ -628,11 +627,10 @@ function template_preprocess_forums(&$variables) { $title = !empty($vocabulary->name) ? $vocabulary->name : ''; // Breadcrumb navigation: - $breadcrumb = array(); + $breadcrumb[] = l(t('Home'), NULL); if ($variables['tid']) { - $breadcrumb[] = array('path' => 'forum', 'title' => $title); + $breadcrumb[] = l($vocabulary->name, 'forum'); } - if ($variables['parents']) { $variables['parents'] = array_reverse($variables['parents']); foreach ($variables['parents'] as $p) { @@ -640,16 +638,13 @@ function template_preprocess_forums(&$variables) { $title = $p->name; } else { - $breadcrumb[] = array('path' => 'forum/'. $p->tid, 'title' => $p->name); + $breadcrumb[] = l($p->name, 'forum/'. $p->tid); } } } - + drupal_set_breadcrumb($breadcrumb); drupal_set_title(check_plain($title)); - $breadcrumb[] = array('path' => $_GET['q']); - menu_set_location($breadcrumb); - if ($variables['forums_defined'] = count($variables['forums']) || count($variables['parents'])) { // Format the "post new content" links listing. $forum_types = array(); diff --git a/modules/taxonomy/taxonomy.pages.inc b/modules/taxonomy/taxonomy.pages.inc index 5ff9cff481eb9c09565e04abeee9abb6d6796ea1..4f86441e9f44436808fdfead21e1ee9a460d0bff 100644 --- a/modules/taxonomy/taxonomy.pages.inc +++ b/modules/taxonomy/taxonomy.pages.inc @@ -32,13 +32,14 @@ function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') { case 'page': // Build breadcrumb based on first hierarchy of first term: $current->tid = $tids[0]; - $breadcrumbs = array(array('path' => $_GET['q'], 'title' => $names[0])); + $breadcrumb = array(); while ($parents = taxonomy_get_parents($current->tid)) { $current = array_shift($parents); - $breadcrumbs[] = array('path' => 'taxonomy/term/'. $current->tid, 'title' => $current->name); + $breadcrumb[] = l($current->name, 'taxonomy/term/'. $current->tid); } - $breadcrumbs = array_reverse($breadcrumbs); - menu_set_location($breadcrumbs); + $breadcrumb[] = l(t('Home'), NULL); + $breadcrumb = array_reverse($breadcrumb); + drupal_set_breadcrumb($breadcrumb); $output = taxonomy_render_nodes(taxonomy_select_nodes($tids, $terms['operator'], $depth, TRUE)); drupal_add_feed(url('taxonomy/term/'. $str_tids .'/'. $depth .'/feed'), 'RSS - '. $title);