Hi

I want to modificate a hook_menu of a module.

Like in http://www.gimme20.com/ i want to add the tabs of modules to the standard user.profile. I think I just have to adjust the path in the hook_menu.

The normal path of a module in the hook_menue is 'path' => 'module/'. $id .'/something',
Im trying to make something like this 'path' => 'user/'.uid.'/module/'. $id .'/something',

But its not working! I do something wrong but was???

I need some help please....

Dirk

CommentFileSizeAuthor
#9 buddylist_tabs.diff12.13 KBmarcoBauli
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DesignWork’s picture

So,

I found out that we have to change the lines 137 and 146 of the buddylist module from

'path' => 'buddylist/'. $id .'/buddies',

to

'path' => 'user/'. $id .'/buddylist/'. $id .'/buddies',

than we will have the two tabs Boddies and Body of in the user.profile.

But now the problem are the sub tabs from line 156 to line 194 there are not shown...... but why?

I will find that out.

Dirk

DesignWork’s picture

Hi Folks,

I made it.
I will post the complete funktion buddylist_menue here. It works fine Now everybody kann have the bodylist in his userprofile (with the tabs etc). I will try to make a step by step explication how to do this in the next days. I think this will work with several drupal modules like favourits, image.gallery etc. I will try that and post it here. The key is hook_menu () read the api of drupal.

Now comes the customized function. Please test it in a testing enviroment.

/**
* Implementation of hook_menu
*/
function buddylist_menu($may_cache) {
global $user;

$items = array();
$id = is_numeric(arg(1)) ? arg(1) : $user->uid;

if ($may_cache) {
// buddylist settings page
$items[] = array(
'path' => 'admin/settings/buddylist',
'title' => t('Buddylist'), // Note that this isn't translated on purpose since it is for the admin
'description' => t('Buddylist configuration options for blocks, email, etc.'),
'callback' => 'drupal_get_form',
'callback arguments' => 'buddylist_admin_settings',
'access' => user_access('administer site configuration'),
);
// my buddylist menu item
$items[] = array(
'path' => 'buddylist',
'title' => t('My @buddylist', buddylist_translation()),
'access' => (user_access('maintain buddy list') && $id),
'callback' => 'buddylist_buddylisting_page',
'callback arguments' => array($user->uid, 'buddies'),
);
}
else {
// 'edit access' only granted to user's own buddy list or to administrative users
$editAccess = (
($id == $user->uid && user_access('maintain buddy list') && $user->uid)
|| user_access('administer users'));

$approval_required = variable_get('buddylist_require_approval', 0);

$items[] = array(
'path' => 'buddy/add',
'title' => t('Add to @buddylist', buddylist_translation()),
'access' => $editAccess,
'callback' => 'drupal_get_form',
'callback arguments' => array('buddylist_addbuddy', arg(2)),
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => 'buddy/delete',
'title' => t('Delete from @buddylist', buddylist_translation()),
'access' => $editAccess,
'callback' => 'drupal_get_form',
'callback arguments' => array('buddylist_deletebuddy', arg(2)),
'type' => MENU_CALLBACK,
);

// 'view only' tabs
$viewAccess = (($id == $user->uid && user_access('maintain buddy list')) || user_access('view buddy lists'));

// If buddylist approval is required, then upon approval, both parties become buddies of each other.
// So, in effect, idea 'buddyof' becomes redundant.
if (!$approval_required) {
$items[] = array(
'path' => 'user/'. $id .'/buddylist/'. $id .'/buddies',
'title' => t('@Buddies', buddylist_translation()),
'access' => $viewAccess,
'callback' => 'buddylist_buddylisting_page',
'type' => MENU_LOCAL_TASK,
'weight' => 1,
'callback arguments' => array($id)
);
$items[] = array(
'path' => 'user/'. $id .'/buddylist/'. $id .'/buddyof',
'title' => t('@Buddyof', buddylist_translation()),
'access' => $viewAccess,
'callback' => 'buddylist_buddylisting_page',
'type' => MENU_LOCAL_TASK,
'weight' => 1,
'callback arguments' => array($id, 'buddyof')
);
}

// subtabs
$items[] = array(
'path' => 'user/'. $id .'/buddylist/'. $id .'/buddies/list',
'title' => t('@Buddylist', buddylist_translation()),
'access' => $viewAccess,
'callback' => 'buddylist_buddylisting_page',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -1,
'callback arguments' => array($id),
);
$items[] = array(
'path' => 'user/'. $id .'/buddylist/'. $id .'/buddies/recent',
'title' => t('Recent posts'),
'access' => ($viewAccess && module_exists('tracker')),
'callback' => 'buddylist_buddiesrecent_page',
'type' => MENU_LOCAL_TASK,
'weight' => 3,
'callback arguments' => array($id),
);
if (variable_get('buddylist_buddygroups', FALSE)) {
$items[] = array(
'path' => 'user/'. $id .'/buddylist/'. $id .'/buddies/groups/view',
'title' => t('View groups'),
'access' => $viewAccess,
'callback' => 'buddylist_buddiesgroups_page',
'type' => MENU_LOCAL_TASK,
'weight' => 5,
'callback arguments' => array($id),
);
$items[] = array(
'path' => 'user/'. $id .'/buddylist/'. $id .'/buddies/groups/edit',
'title' => t('Edit groups'),
'access' => $editAccess,
'callback' => 'buddylist_buddiesgroups_edit',
'type' => MENU_LOCAL_TASK,
'weight' => 6,
'callback arguments' => array($id),
);
}

// sub-subtabs
if ($approval_required && $editAccess) {
$items[] = array(
'path' => 'user/'. $id .'/buddylist/'. $id .'/buddies/requests',
'title' => t('Pending requests'),
'access' => $editAccess,
'callback' => 'theme',
'type' => MENU_LOCAL_TASK,
'weight' => 0,
'callback arguments' => array('buddylist_pending_requests', $id)
);

$items[] = array(
'path' => 'user/'. $id .'/buddylist/'. $id .'/buddies/requested/accept',
'title' => t('Accept Request'),
'access' => $editAccess,
'type' => MENU_CALLBACK,
'callback' => 'drupal_get_form',
'callback arguments' => array('buddylist_pending_requested_accept',$id),
);

$items[] = array(
'path' => 'user/'. $id .'/buddylist/'. $id .'/buddies/requested/deny',
'title' => t('Deny Request'),
'access' => $editAccess,
'type' => MENU_CALLBACK,
'callback' => 'drupal_get_form',
'callback arguments' => array('buddylist_pending_requested_deny',$id),
);

$items[] = array(
'path' => 'user/'. $id .'/buddylist/'. $id .'/buddies/request/cancel',
'title' => t('Cancel Request'),
'access' => $editAccess,
'type' => MENU_CALLBACK,
'callback' => 'drupal_get_form',
'callback arguments' => array('buddylist_cancel_request',$id),
);

}

// other callbacks
if ($id != $user->uid) {
// This callback can interfere with the 'my buddylist' menu item,
// so we only load it if the user is viewing another user's list.
$items[] = array(
'path' => 'user/'. $id .'/buddylist/'. $id,
'title' => t('@Buddylist', buddylist_translation()),
'access' => (($viewAccess || $editAccess) && $id),
'callback' => 'buddylist_buddylisting_page',
'type' => MENU_CALLBACK,
'callback arguments' => array($id),
);
}
$items[] = array(
'path' => 'user/'. $id .'/buddylist/'. $id .'/buddies/recent/feed',
'title' => t('Xml feed'),
'access' => $viewAccess,
'callback' => 'buddylist_buddyfeed',
'type' => MENU_CALLBACK,
'callback arguments' => array($id),
);
}

return $items;
}

Have fun with it.

Dirk

smitty’s picture

That are great news. This is exactly what I was waiting for.

I would love to join the testing.

Where do I have to copy the function to? And which other chances are necessary?
Perhaps you can provide a patch or add it to a release?

smitty’s picture

Of course I meant "changes", not "chances".

DesignWork’s picture

Hi Folks,

this is a custom snippet. In the budylist you have the funktion: function buddylist_menu, replace the old code of the funktion with this one.

Have Fun.

Dirk

smitty’s picture

I have copied the function into the buddylist.module and it works quite fine.

But firstly I can't see any difference between the two tabs "view" and "buddylist" now.
And secondly in my opinion the account page now gets a little confusing with all the tabs on it.

Wouldn't it be better to have only one tab "buddylist" on it and to put the rest (buddies [as a merger of buddylist and view groups, see: http://drupal.org/node/134614] pending requests, recent posts, edit groups) onto some sub-tabs?

DesignWork’s picture

Hi smitty,

you can change everything as you want. I made more changes to the buddylist.module. You can have a look here. www.karstenschoene.de/dirksway Login: Gast, pasword: gast . This is a testsite for a new communitypage. At the moment its just a dummy for the useabbility, with no design.

You just have to change code in the module. Just tell me what exactly do you need? I can try do give you a coustom version of the module.

Dirk

Rosamunda’s picture

Worked like a charm for me THANKS Dirk!

marcoBauli’s picture

Status: Active » Needs review
FileSize
12.13 KB

wow, is very logic to display the buddylist in a tab this way, i was looking for that!

Should be added as a choice in the settings of the module IMO

Thanks man

PS: rolled a patch out of Dirk code for others to review

scottee’s picture

thanks i'll try this and report my results shortly

apaderno’s picture

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

I am closing this issue, as it has been created for a release that is now not supported.