It can be done.
Here's the code (starts at line 134 and finishes at line 186 of modules/blog/blog.module).
/**
* Implementation of hook_menu().
*/
function blog_menu() {
//Original menu_router entry, left in to preserve View menu.
//Not sure what was going on there, but my View menu vanished every time I changed ['blog'] to ['blogs'].
$items['blog'] = array(
'title' => 'Blogs',
'page callback' => 'blog_page_last',
'access arguments' => array('access content'),
'type' => MENU_SUGGESTED_ITEM,
'file' => 'blog.pages.inc',
);
//Original menu_router item, generates a current user blog tab and "view".
$items['blog/%user_uid_optional'] = array(
'title' => 'My blog',
'page callback' => 'blog_page_user',
'page arguments' => array(1),
'access callback' => 'blog_page_user_access',
'access arguments' => array(1),
'type' => MENU_LOCAL_TASK,
'file' => 'blog.pages.inc',
);
//New menu_router entry, generates a "shell" (?), an empty "view" for the tabs to display themselves and their contents in.
//Figured this out by looking at tracker.module.
$items['blogs'] = array(
'title' => 'Blogs',
'page callback' => 'blog_page_last',
'access arguments' => array('access content'),
'type' => MENU_SUGGESTED_ITEM,
'file' => 'blog.pages.inc',
);
//New menu_router entry, generates a tab and "view" for all blogs on the site.
$items['blogs/all'] = array(
'title' => 'All blogs',
'type' => MENU_DEFAULT_LOCAL_TASK,
//'file' => 'blog.pages.inc',
);
//New menu_router item, generates a tab and "view" for current user's blog.
$items['blogs/%user_uid_optional'] = array(
'title' => 'My blog',
'page callback' => 'blog_page_user',
'page arguments' => array(1),
'access callback' => 'blog_page_user_access',
'access arguments' => array(1),
'type' => MENU_LOCAL_TASK,
'file' => 'blog.pages.inc',
);
And here's a screen shot of the results--after you run update.php.
Comments
Comment #1
markpenny commentedBetter title.
Comment #2
jumoke commentedThis doesn't work for me. My screen goes blank
Comment #3
markpenny commentedActually, a more efficient method is to use Views. The problem with changing the code is that you have to change it every time you update. If you use Views to generate tabs, the records are retained.
I'd be happy to tutor you on using Views to create tabs if you'd like.
Comment #4
jumoke commentedHi Mark, that would be great thanks.
Comment #5
markpenny commentedAre you in a great rush?
Comment #6
markpenny commentedCreating Tabs using Views
Comment #7
deekayen commented#233301-125: Remove blog module from core removed blog from core.
Comment #8
cazare particulari commentedit a old blog , but is fullhelping for me to configure blod drupal . thank you
Comment #10
markpenny commentedThis used to be on my blog, but that blog is now defunct. I haven't run my own site for a couple of years now, and drupal may have changed a bit, but here's the tutorial anyway.
Creating Tabs using Views
You can create a Tab anywhere on your Drupal site using the Views module. This technique is preferable to altering code, because the alterations are saved in the database and are preserved when you update or upgrade your installation. Tabs created in code are lost when the database updates using new installation files.
To create a Tab using the Views module,
Navigate to Site building>Views (admin/build/views).
Open or add a View.
Alter the View's Default settings as desired.
Add a Display (probably a Page).
Alter Basic settings, Relationships, Arguments, Fields, Sort criteria and Filters as desired.
Assuming the display is a Page, under Page settings, click Path and enter the desired path. The path for a Tab includes a base path, which tells the Tab which page to appear on. For example, the path for a Blog tab on a user's Account page must include the base path user/%/ and the path name of the page assigned to the Tab (e.g., user/%/blog).
Click Update.
Under Page settings, click Menu and select either Menu tab or Default menu tab. Default menu tab makes the tabbed page the default page for the View that contains it.
Alter Title, Description and Weight as desired. The Title is the text that will appear in the Tab. The Description is the text that will appear when the Tab is moused over. The Weight is the position of the Tab among other Tabs with the same base path. Tabs with the same Weight are sorted alphabetically.
Click Update.
Click Save.
If the Tab path contains an argument (represented by a percent sign, as in the example user/%/blog),
Click the plus sign next to Argument.
Select the Argument group (e.g., User) in the Groups dropdown menu.
Check the Argument type (e.g., User: ID).
Click Add.
Under Validator options, select the Validator (e.g, User) from the Validator dropdown menu.
Click Update.
Click Save.
Comment #14
deekayen commentedfixing spam title
Comment #15
nevergoneOutdated issue.