By donnoit on
I am hoping to add "my blog" as a menu item, just like "my account" is available today. The mass_url module makes 'q=blog/username' path possible as a valid url to the blog of a user.
Creation of a menu item, however does not seem to allow "blog/%username" as the valid path (does not evaluate the %username variable).
Does anyone have any suggestions as to how can I make that path available thru the menu to every user after he/she logs in?
Comments
A hacked workaround..
I solved my problem by hacking the user.module and inserting the following code to emulate creation of the 'my account' menu-item.
$items[] = array('path' => 'blog/'. $user->name, 'title' => t('my blog'),
'callback' => 'user_page', 'access' => TRUE,
'type' => MENU_DYNAMIC_ITEM);
This works - 'my blog' menu provides a direct path to the logged in user's own blog - so long as mass_url module is installed and enabled.
Would still appreciate any insights to a cleaner solution.
Re: A hacked workaround..
I suspect this more properly belongs in the blog module. I added this to the blog.module blog_menu() function:
No mass_url filtering required, unless you want to convert the user id to user name.
thanks and a small modification
Thanks jchris.
I like your solution better than mine except that the 'my blog' shows up in the menu even when no one is logged in.
The following check around your code fixes that: