By default the users blog page (blog/uid) is set to "My blog" in the hook_menu.

But this title is never showing up on the blog page of a user because in the function blog_page_user($account) the title is explicitly set to "username's blog". This is true even if the current user is viewing his own blog page.

To avoid this, the title in blog_page_user should only be set to "username's blog" if the current user is viewing a blog page of an other user.

So in the function blog_page_user we should change

drupal_set_title($title = t("@name's blog", array('@name' => format_username($account))), PASS_THROUGH);

to

if ($account->uid <> $user->uid) {
  drupal_set_title($title = t("@name's blog", array('@name' => format_username($account))), PASS_THROUGH);
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

furamag’s picture

I have checked Drupal 6 functionality and I have same title "username's blog" on page blog/uid . Are you sure this issue is bug?

When I'm using your code I have following error:

Notice: Undefined variable: title in blog_page_user() (line 67 of C:\sites\drupal7\modules\blog\blog.pages.inc).

I think we should replace

drupal_set_title($title = t("@name's blog", array('@name' => format_username($account))), PASS_THROUGH);

to

if ($account->uid <> $user->uid) {
  drupal_set_title($title = t("@name's blog", array('@name' => format_username($account))), PASS_THROUGH);
}
else {
  $title = drupal_get_title();
}
smitty’s picture

Well I think this is the same bug as in D5 and D6. But nonetheless it seems a bug to me, even if it's an old bug.

The error you mentioned might occur because the menu system changed since D5 (I really did the change in D5 ant there it works fine.

I think your code is ok.

marcingy’s picture

Version: 7.x-dev » 8.x-dev
Assigned: Unassigned » marcingy
Category: bug » task
Issue tags: +Needs backport to D7

This is still an issue in head - bumping to d8. Will take a look at this. Moving to a task as it is more a wtf rather than a true bug.

marcingy’s picture

Status: Active » Needs review
FileSize
4.63 KB

Amends logic for both the blog page and the blog feed page.

joachim’s picture

Status: Needs review » Needs work

+1 to this.

A few tweaks needed to the patch however.

+++ b/modules/blog/blog.module
@@ -115,7 +115,7 @@ function blog_menu() {
-    'title' => 'Blogs',
+    'title' => 'My Blog',

Should we really be changing hook_menu?

+++ b/modules/blog/blog.pages.inc
@@ -10,8 +10,13 @@
+  ¶

Whitespace :/

+++ b/modules/blog/blog.pages.inc
@@ -10,8 +10,13 @@
+  if ($user->uid != $account->uid) {
+    drupal_set_title($title = t("@name's blog", array('@name' => format_username($account))), PASS_THROUGH);
+  }
+  else {
+    $title = drupal_get_title();
+  }
 

I don't understand what the else part is doing here. Ohhh wait I get it -- you're falling back to what is set in hook_menu.

I don't think this is a good idea -- you're defining the title in two places that are miles apart in the code.

+++ b/modules/blog/blog.test
@@ -79,6 +79,14 @@ class BlogTestCase extends DrupalWebTestCase {
+    // Check the title when viewing another users blog.

Should be "user's".

10 days to next Drupal core point release.

marcingy’s picture

Status: Needs work » Needs review
FileSize
4.17 KB

Reroll taking into account comments above.

deekayen’s picture

Project: Drupal core » Blog
Version: 8.x-dev » 8.x-2.x-dev
Component: blog.module » User interface
nevergone’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

Outdated issue.