1

I have enabled the Blog module in order to have a blog for every user. Now I want to create a tab in each user profile that it links to that user's blog.

Is it possible? How can I do this?

2 Answers 2

0

You can also do this by either using the Views module or the Page manager module, without any custom coding:

  • With the Views module, you could create a list of all blog posts by a user, and display that as a tab on the user's page. However, it would not be the same list as the one the Blog module creates (though it could look the same). A guide for using Views can be found here: http://nodeone.se/blogg/learn-views-with-nodeone-part-1-overview – in particular check out episode 21 for this use case.
  • With the Page manager module, you could create a tab that redirects to the blog list page for that user. However, the visitor would end up on the blog list page – which does not have tabs for returning to the previous page. See Learn Page manager! for an introduction to this module.

In general, I would recommend that you build your own blog using custom content types and the Views module – it will give you more flexibility in the long run.

Good luck!

1
  • Thank you. I used page manager and managed to get it working.
    – Pavlos
    Commented Sep 6, 2011 at 8:54
1

Using a custom module, you can implement hook_menu() in the following way:

function mymodule_menu() {
  $items['user/%user/blog'] = array(
    'title' => 'My blog', 
    'page callback' => 'blog_page_user', 
    'page arguments' => array(1), 
    'access callback' => 'blog_page_user_access', 
    'access arguments' => array(1),
    'file path' => drupal_get_path('module', 'blog'), 
    'file' => 'blog.pages.inc',
  );

  return $items;
}

The "file path" property is used because the module that defines the menu is not the one containing the "blog.pages.inc" file.

If you have few experience on how to create a Drupal module, you should start looking at:

2
  • Thank you for your answer. As a beginner to php and Drupal i tried to follow your instructions but i couldn't make them work. I created a folder in sites/all/module named blog_help. There i put a blog_help.info and a blog_help.module file containing your code(i changed mymodule). I enabled the module, cleared the cache but with no result. I use Drupal 6.x and to create the user profile i use the user%user panel page.
    – Pavlos
    Commented Sep 3, 2011 at 21:41
  • I added some links that could help you to write a module.
    – avpaderno
    Commented Sep 3, 2011 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.