hi,

if you to your blog in drupal 7

for example

http://www.drupal.org/blog#

and you don't like the title "Blogs"

You can modify it by editing the file:

Modules>Blog>blog.module

and in the section:

function blog_menu() {
  $items['blog'] = array(
    'title' => 'Blogs',
    'page callback' => 'blog_page_last',
    'access arguments' => array('access content'),
    'type' => MENU_SUGGESTED_ITEM,
    'file' => 'blog.pages.inc',

you can change title element of array into what you want.

Example:

function blog_menu() {
  $items['blog'] = array(
    'title' => 'These are the blog entries of all users in this system',
    'page callback' => 'blog_page_last',
    'access arguments' => array('access content'),
    'type' => MENU_SUGGESTED_ITEM,
    'file' => 'blog.pages.inc',

Or remove the title :

function blog_menu() {
  $items['blog'] = array(
    'page callback' => 'blog_page_last',
    'access arguments' => array('access content'),
    'type' => MENU_SUGGESTED_ITEM,
    'file' => 'blog.pages.inc',

hope it helps someone

greetings

Comments

Anonymous’s picture

Don't modify the module, or you'll have to make that mod every time you update Drupal.
Instead, just change it at http://example.com/admin/structure/menu.
You can change the title of most menu items using the admin interface.

Doug Gough

ben.hamelin’s picture

This title can not be edited via /admin/structure/menu above

The proper way to do this is in the TEMPLATENAME_preprocess_page() function from within your theme's template.php file.

However, some interesting notes follow:

1) when I manually changed the 'Blogs' text as described above, I could not the title to change
2) editing the menu_router entry for path='blog' ALSO did not work (of course clearing the cache will reset this value to 'Blogs' based on the .module hook_menu setting if you've left this alone
3) within template.php, preprocess_page, the $vars['title'] variable is undefined

In short, using the prescribed methods, I was not able to get this to work. Additional comments would be greatly appreciated.

What I ended up doing was keying in on the $_SERVER['REQUEST_URI'] value, and manually setting $vars['title'] = 'My BLog Title'; in my preprocess_page function

Very strange

amul_mitm’s picture

Edit the 'Blogs' title in the breadcrumb process function. Like this:

$title = drupal_get_title();
		if ($title == 'Blogs')
			$breadcrumb[] = 'Blog';
		else 
			$breadcrumb[] = $title;
		
		return implode(' » ', $breadcrumb);

This way I got it to work, but I don't know if this is good to check title in every breadcrumb call.

@ben.hamelin I wonder why I didn't find your post before, I've been unsuccessfully trying what you said minutes before I posted this.

bel.inna’s picture

Think better solution is:

function my_module_name_menu_alter(&$items) {
  if (isset($items['blog'])) {
        $items['blog']['title'] = 'Blog Name';
  }
}
muhammad.tanweer’s picture

Changing the menu item's title from admin panel works. It changes the page title.

Muhammad.

mrcniceguy’s picture

Thankx @Bel.inna ,This worked for me.

damon hart’s picture

You need to change this in the Navigation Menu as well as the Main Menu in Drupal 7... I hope this helps to clarify for other users like me who didn't understand this at first.

Sophiej’s picture

raynimmo’s picture

I have found by far the easiest method for doing this is by analyzing the current Drupal path by reading the current arg(0) variable.

see http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/arg/7

  if (arg(0) == 'contact') {
    $title = 'Get In Touch';
  }
  if (arg(0) == 'blog') {
    $title = 'My Thoughts';
  }

Paste this section of code at the top of your theme's page.tpl.php within PHP tags
<?php ... ?>

This works for Drupal 6 and Drupal 7.

raynimmo’s picture

Reading the page at http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/arg/7, it does intimate that the use of the arg() variable is frowned upon in this instance although purely for readability issues.

Avoid use of this function where possible, as resulting code is hard to read. In menu callback functions, attempt to use named arguments.

A cleaner method would be to read the $path variable as such:

  if (!isset($path)) {
    $nodepath = $_GET['q'];
  }

  if ($nodepath == 'contact') {
    $title = 'Get In Touch';
  }
  if ($nodepath == 'blog') {
    $title = 'My Thoughts';
  }
thelastog’s picture

String Overrides does change title but the link is still @ www.mysite.com/blog

videodoll’s picture

by adding an alias in configuration / URL alias

I used string override to change the title of my Blog. Frustrating to have to use a module to do something that should be so simple - why isn't there a simple "blog settings".

At the same time, the other easy solution is so make a view that you use as the blog and give it whatever name you want.

I was a little to lazy to do that. String override worked!

i have a feeling a view will be the better solution in my case, because right now, I can't remember how to control the number of posts per page or the pager... Just seems like I have very little control over the default blog.

ashishdalvi’s picture

Use this code to generate the dynamic menu title and page title.

function testing_menu_alter(&$items){
  $items['blog']['title callback'] = 'custom_title_callback';
}

function custom_title_callback() {
  $now = format_date(time());
  return t('Current @time', array('@time' => $now));
}