<div dir="ltr"><br>I thing This code enough for u,<br><br>Just copy this module into your site/module.... <br><br><div class="gmail_quote">On Mon, Jul 28, 2008 at 10:46 PM, Metzler, David <span dir="ltr"><<a href="mailto:metzlerd@evergreen.edu">metzlerd@evergreen.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">The reason that these menus is because a.) they appear in the if<br>
(!$may_cache) section of the hook_menu and b.) thay are wrapped in an if<br>
($user !== FALSE) condition.<br>
<br>
Note that there is also a separate /user path registered in the if<br>
($may_cache) section of the hook_menu. This is the "default" path for<br>
/user and what shows up in the admin/menu screen.<br>
<br>
You may be grappling with one of the core troubles with Drupal 5. Only<br>
menus that are in the if ($may_cache) section of the module may be moved<br>
around with the admin/menu user interface. If it's a dynamic menu, you<br>
just don't see it there. So if you make a dynamic menu item, you can't<br>
turn around and move it into a block. Although you may be able to move<br>
a the static parent menu item (defined in the if ($may_cache) section of<br>
the menu into a separate menu and menu block. This took me a little time<br>
to grok.<br>
<br>
Finally you can't have the code define a new menu, but only create a<br>
menu tree section in code and then move it later using the admin menu<br>
interface.<br>
<br>
Is that clearing any of this up for you?<br>
<br>
<br>
Here's the relavent chunk of user_menu code for understanding.<br>
if ($may_cache) {<br>
$items[] = array('path' => 'user', 'title' => t('User account'),<br>
'callback' => 'drupal_get_form', 'callback arguments' =><br>
array('user_login'),<br>
'access' => !$user->uid, 'type' => MENU_CALLBACK);<br>
<br>
$items[] = array('path' => 'user/autocomplete', 'title' => t('User<br>
autocomplete'),<br>
'callback' => 'user_autocomplete', 'access' => $view_access,<br>
'type' => MENU_CALLBACK);<br>
... Bunch of code ommitted....<br>
<br>
} else {<br>
... Some code ommitted.<br>
if ($user !== FALSE) {<br>
// Always let a user view their own account<br>
$view_access |= $user->uid == arg(1);<br>
// Only admins can view blocked accounts<br>
$view_access &= $account->status || $admin_access;<br>
<br>
$items[] = array('path' => 'user/'. arg(1), 'title' =><br>
t('User'),<br>
'type' => MENU_CALLBACK, 'callback' => 'user_view',<br>
'callback arguments' => array(arg(1)), 'access' =><br>
$view_access);<br>
<br>
$items[] = array('path' => 'user/'. arg(1) .'/view', 'title' =><br>
t('View'),<br>
'access' => $view_access, 'type' => MENU_DEFAULT_LOCAL_TASK,<br>
'weight' => -10);<br>
<br>
$items[] = array('path' => 'user/'. arg(1) .'/edit', 'title' =><br>
t('Edit'),<br>
'callback' => 'drupal_get_form', 'callback arguments' =><br>
array('user_edit'),<br>
'access' => $admin_access || $user->uid == arg(1), 'type' =><br>
MENU_LOCAL_TASK);<br>
$items[] = array('path' => 'user/'. arg(1) .'/delete', 'title'<br>
=> t('Delete'),<br>
'callback' => 'user_edit', 'access' => $admin_access,<br>
'type' => MENU_CALLBACK);<br>
<br>
if (arg(2) == 'edit') {<br>
if (($categories = _user_categories($account)) &&<br>
(count($categories) > 1)) {<br>
foreach ($categories as $key => $category) {<br>
$items[] = array(<br>
'path' => 'user/'. arg(1) .'/edit/'. $category['name'],<br>
'title' => $category['title'],<br>
'type' => $category['name'] == 'account' ?<br>
MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,<br>
'weight' => $category['weight'],<br>
'access' => ($admin_access || $user->uid == arg(1)));<br>
<div class="Ih2E3d"> }<br>
}<br>
}<br>
}<br>
}<br>
-----Original Message-----<br>
From: <a href="mailto:support-bounces@drupal.org">support-bounces@drupal.org</a> [mailto:<a href="mailto:support-bounces@drupal.org">support-bounces@drupal.org</a>] On<br>
</div><div class="Ih2E3d">Behalf Of Ivan Sergio Borgonovo<br>
Sent: Monday, July 28, 2008 8:43 AM<br>
To: <a href="mailto:support@drupal.org">support@drupal.org</a><br>
Subject: Re: [support] tutorial on dynamically generating menu in D5<br>
<br>
</div><div><div></div><div class="Wj3C7c">On Mon, 28 Jul 2008 16:07:50 +0200<br>
Florent JOUSSEAUME <<a href="mailto:florent.jousseaume@makina-corpus.com">florent.jousseaume@makina-corpus.com</a>> wrote:<br>
<br>
> For your example, this is not a switch, but 2 modules with differents<br>
> ACL. The block 'login' is displayed for 'Anonymous' and the menu is<br>
> displayed for 'Authenticated user' (block Navigation).<br>
><br>
> For the element's visibility in the menu, this is with the user_access<br>
<br>
> method defined in the function 'hook_menu' for each module.<br>
<br>
It looks a bit hakish.<br>
And I still can't get it completely.<br>
<br>
1)<br>
path user points to user_login if(uid) otherwise it should point to<br>
something else... but what is the alternative?<br>
In user_menu all paths are user/[something else] or admin/user/...<br>
I can't understand why once the user is logged in and the path<br>
user/[uid] becomes available the path /user reaches user_view<br>
<br>
2)<br>
I can't yet understand the magic that make -My account appear in the<br>
Menu admin pages as locked. I still haven't had the time to read the<br>
code.<br>
<br>
3)<br>
I miss how I can *render* menu with the admin interface and/or in<br>
modules.<br>
I'd expect that if I build up a $items hierarchy I could build up a menu<br>
from the "admin" interface adding a path and the menu system will take<br>
care of rendering children once I eg. put the menu in a block.<br>
What if I'd like to render the menu inside my code? I think I should use<br>
menu_tree... but well I bet there are a lot of tricks I could learn<br>
without guessing them from the API.<br>
<br>
4) I haven't seen any tutorial, handbook... on any of the menu_ family<br>
of function.<br>
There is nothing on "Pro Drupal development" book.<br>
<br>
thanks<br>
<br>
--<br>
Ivan Sergio Borgonovo<br>
<a href="http://www.webthatworks.it" target="_blank">http://www.webthatworks.it</a><br>
<br>
--<br>
[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
--<br>
[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
</div></div></blockquote></div><br></div>