Commit cb7c2e09 authored by Dries's avatar Dries

- Fixed the breadcrumb trail of nested forums.  Patch by Goba.
parent 4c06410d
......@@ -154,22 +154,19 @@ function forum_view($node, $main = 0, $page = 0) {
// we are previewing
$term_data = taxonomy_get_term($node->taxonomy[0]);
}
$voc = taxonomy_get_vocabulary($term_data->vid);
// Breadcrumb navigation
$breadcrumb[] = l(t("Home"), NULL);
$breadcrumb[] = l(t("forums"), "forum");
$breadcrumb[] = l($term_data->name, "forum/$term_data->tid");
// print the breadcrumb
$breadcrumb = array(l(t("Home"), NULL), l(t("forum"), "forum"));
if ($parents = taxonomy_get_parents_all($term_data->tid)) {
$parents = array_reverse($parents);
foreach ($parents as $p) {
$breadcrumb[] = l($p->name, "forum/$p->tid");
}
}
drupal_set_breadcrumb($breadcrumb);
}
// prepare the node content
$node = forum_content($node);
// print the node
$output .= theme("node", $node, $main, $page);
return $output;
return theme("node", forum_content($node), $main, $page);
}
function forum_validate(&$node) {
......@@ -287,19 +284,6 @@ function forum_get_forums($tid = 0) {
return $forums;
}
function forum_get_parents($tid) {
if ($tid) {
$parents[] = taxonomy_get_term($tid);
}
$n = 0;
while ($parent = taxonomy_get_parents($parents[$n]->tid)) {
$parents = array_merge($parents, $parent);
$n++;
}
return $parents;
}
function _forum_num_topics($term) {
$value = db_fetch_object(db_query("SELECT COUNT(n.nid) AS count FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid WHERE f.tid = %d AND n.nid = f.nid AND n.status = 1 AND n.type = 'forum'", $term));
return ($value) ? $value->count : 0;
......@@ -444,7 +428,7 @@ function forum_page() {
$offset = ($from / $forum_per_page) + 1;
$forums = forum_get_forums($tid);
$parents = forum_get_parents($tid);
$parents = taxonomy_get_parents_all($tid);
if ($tid && !in_array($tid, variable_get("forum_containers", array()))) {
$topics = forum_get_topics($tid, $sortby, $forum_per_page);
}
......
......@@ -154,22 +154,19 @@ function forum_view($node, $main = 0, $page = 0) {
// we are previewing
$term_data = taxonomy_get_term($node->taxonomy[0]);
}
$voc = taxonomy_get_vocabulary($term_data->vid);
// Breadcrumb navigation
$breadcrumb[] = l(t("Home"), NULL);
$breadcrumb[] = l(t("forums"), "forum");
$breadcrumb[] = l($term_data->name, "forum/$term_data->tid");
// print the breadcrumb
$breadcrumb = array(l(t("Home"), NULL), l(t("forum"), "forum"));
if ($parents = taxonomy_get_parents_all($term_data->tid)) {
$parents = array_reverse($parents);
foreach ($parents as $p) {
$breadcrumb[] = l($p->name, "forum/$p->tid");
}
}
drupal_set_breadcrumb($breadcrumb);
}
// prepare the node content
$node = forum_content($node);
// print the node
$output .= theme("node", $node, $main, $page);
return $output;
return theme("node", forum_content($node), $main, $page);
}
function forum_validate(&$node) {
......@@ -287,19 +284,6 @@ function forum_get_forums($tid = 0) {
return $forums;
}
function forum_get_parents($tid) {
if ($tid) {
$parents[] = taxonomy_get_term($tid);
}
$n = 0;
while ($parent = taxonomy_get_parents($parents[$n]->tid)) {
$parents = array_merge($parents, $parent);
$n++;
}
return $parents;
}
function _forum_num_topics($term) {
$value = db_fetch_object(db_query("SELECT COUNT(n.nid) AS count FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid WHERE f.tid = %d AND n.nid = f.nid AND n.status = 1 AND n.type = 'forum'", $term));
return ($value) ? $value->count : 0;
......@@ -444,7 +428,7 @@ function forum_page() {
$offset = ($from / $forum_per_page) + 1;
$forums = forum_get_forums($tid);
$parents = forum_get_parents($tid);
$parents = taxonomy_get_parents_all($tid);
if ($tid && !in_array($tid, variable_get("forum_containers", array()))) {
$topics = forum_get_topics($tid, $sortby, $forum_per_page);
}
......
......@@ -437,6 +437,20 @@ function taxonomy_get_parents($tid, $key = "tid") {
}
}
// Gets all parents, parents of parents, etc.
function taxonomy_get_parents_all($tid, $key = "tid") {
$parents = array();
if ($tid) {
$parents[] = taxonomy_get_term($tid);
$n = 0;
while ($parent = taxonomy_get_parents($parents[$n]->tid)) {
$parents = array_merge($parents, $parent);
$n++;
}
}
return $parents;
}
// hierarchy: get children
function taxonomy_get_children($tid, $vid = 0, $key = "tid") {
if ($vid) {
......
......@@ -437,6 +437,20 @@ function taxonomy_get_parents($tid, $key = "tid") {
}
}
// Gets all parents, parents of parents, etc.
function taxonomy_get_parents_all($tid, $key = "tid") {
$parents = array();
if ($tid) {
$parents[] = taxonomy_get_term($tid);
$n = 0;
while ($parent = taxonomy_get_parents($parents[$n]->tid)) {
$parents = array_merge($parents, $parent);
$n++;
}
}
return $parents;
}
// hierarchy: get children
function taxonomy_get_children($tid, $vid = 0, $key = "tid") {
if ($vid) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment