diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module
index e9cd043..8044c25 100644
--- a/core/modules/forum/forum.module
+++ b/core/modules/forum/forum.module
@@ -100,6 +100,8 @@ function forum_menu() {
);
$items['forum/%forum_forum'] = array(
'title' => 'Forums',
+ 'title callback' => 'forum_page_title',
+ 'title arguments' => array(1),
'page callback' => 'forum_page',
'page arguments' => array(1),
'access arguments' => array('access content'),
@@ -164,6 +166,13 @@ function forum_menu() {
}
/**
+ * Menu item title callback - use the forum name.
+ */
+function forum_page_title($forum_term) {
+ return $forum_term->name;
+}
+
+/**
* Implements hook_menu_local_tasks_alter().
*/
function forum_menu_local_tasks_alter(&$data, $router_item, $root_path) {
@@ -989,32 +998,7 @@ function forum_preprocess_block(&$variables) {
* @see forums.tpl.php
*/
function template_preprocess_forums(&$variables) {
- global $user;
-
$config = config('forum.settings');
- $vid = $config->get('vocabulary');
- $vocabulary = taxonomy_vocabulary_load($vid);
- $title = !empty($vocabulary->name) ? $vocabulary->name : '';
-
- // Breadcrumb navigation:
- $breadcrumb[] = l(t('Home'), NULL);
- if ($variables['tid']) {
- $breadcrumb[] = l($vocabulary->name, 'forum');
- }
- if ($variables['parents']) {
- $variables['parents'] = array_reverse($variables['parents']);
- foreach ($variables['parents'] as $p) {
- if ($p->tid == $variables['tid']) {
- $title = $p->label();
- }
- else {
- $breadcrumb[] = l($p->label(), 'forum/' . $p->tid);
- }
- }
- }
- drupal_set_breadcrumb($breadcrumb);
- drupal_set_title($title);
-
if ($variables['forums_defined'] = count($variables['forums']) || count($variables['parents'])) {
if (!empty($variables['forums'])) {
$variables['forums'] = theme('forum_list', $variables);
@@ -1025,7 +1009,6 @@ function template_preprocess_forums(&$variables) {
if ($variables['tid'] && !in_array($variables['tid'], $config->get('containers'))) {
$variables['topics'] = theme('forum_topic_list', $variables);
- drupal_add_feed('taxonomy/term/' . $variables['tid'] . '/feed', 'RSS - ' . $title);
}
else {
$variables['topics'] = '';
@@ -1049,7 +1032,6 @@ function template_preprocess_forums(&$variables) {
}
else {
- drupal_set_title(t('No forums defined'));
$variables['forums'] = '';
$variables['topics'] = '';
}
@@ -1154,7 +1136,7 @@ function template_preprocess_forum_topic_list(&$variables) {
$variables['topics'][$id]->new_text = '';
$variables['topics'][$id]->new_url = '';
if ($topic->new_replies) {
- $variables['topics'][$id]->new_text = format_plural($topic->new_replies, '1 new post in topic %title', '@count new posts in topic %title', array('%title' => $original_title));
+ $variables['topics'][$id]->new_text = format_plural($topic->new_replies, '1 new post in topic %title', '@count new posts in topic %title', array('%title' => $topic->title));
$variables['topics'][$id]->new_url = url("node/$topic->nid", array('query' => comment_new_page_count($topic->comment_count, $topic->new_replies, $topic), 'fragment' => 'new'));
}
diff --git a/core/modules/forum/forum.pages.inc b/core/modules/forum/forum.pages.inc
index b4a90ab..e0c5f77 100644
--- a/core/modules/forum/forum.pages.inc
+++ b/core/modules/forum/forum.pages.inc
@@ -24,11 +24,39 @@ function forum_page($forum_term = NULL) {
$forum_term = forum_forum_load(0);
}
+ // Breadcrumb navigation.
+ $breadcrumb[] = l(t('Home'), NULL);
+ if ($forum_term->tid) {
+ // Parent of all forums is the vocabulary name.
+ $vocabulary = entity_load('taxonomy_vocabulary', $config->get('vocabulary'));
+ $breadcrumb[] = l($vocabulary->label(), 'forum');
+ }
+ // Add all parent forums to breadcrumbs.
+ if ($forum_term->parents) {
+ foreach (array_reverse($forum_term->parents) as $parent) {
+ if ($parent->id() != $forum_term->tid) {
+ $breadcrumb[] = l($parent->label(), 'forum/' . $parent->id());
+ }
+ }
+ }
+ drupal_set_breadcrumb($breadcrumb);
+
+ $containers = $config->get('containers');
+ if ($forum_term->tid && array_search($forum_term->tid, $containers) === FALSE) {
+ // Add RSS feed for forums.
+ drupal_add_feed('taxonomy/term/' . $forum_term->id() . '/feed', 'RSS - ' . $forum_term->label());
+ }
+
+ if (empty($forum_term->forums) && empty($forum_term->parents)) {
+ // Root of empty forum.
+ drupal_set_title(t('No forums defined'));
+ }
+
$forum_per_page = $config->get('topics.page_limit');
- $sortby = $config->get('topics.order');
+ $sort_by = $config->get('topics.order');
if (empty($forum_term->container)) {
- $topics = forum_get_topics($forum_term->tid, $sortby, $forum_per_page);
+ $topics = forum_get_topics($forum_term->tid, $sort_by, $forum_per_page);
}
else {
$topics = '';
@@ -40,12 +68,9 @@ function forum_page($forum_term = NULL) {
'#topics' => $topics,
'#parents' => $forum_term->parents,
'#tid' => $forum_term->tid,
- '#sortby' => $sortby,
+ '#sortby' => $sort_by,
'#forums_per_page' => $forum_per_page,
);
$build['#attached']['css'][] = drupal_get_path('module', 'forum') . '/forum.css';
- // @todo Returning a render array causes template_preprocess_forums() to be
- // invoked too late and the breadcrumb is rendered before that callback
- // adjusted it.
- return drupal_render($build);
+ return $build;
}