<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">&lt;<a href="mailto:metzlerd@evergreen.edu">metzlerd@evergreen.edu</a>&gt;</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 &quot;default&quot; 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. &nbsp;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. &nbsp;If it&#39;s a dynamic menu, you<br>
just don&#39;t see it there. &nbsp;So if you make a dynamic menu item, you can&#39;t<br>
turn around and move it into a block. &nbsp;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&#39;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&#39;s the relavent chunk of user_menu code for understanding.<br>
 &nbsp;if ($may_cache) {<br>
 &nbsp; &nbsp;$items[] = array(&#39;path&#39; =&gt; &#39;user&#39;, &#39;title&#39; =&gt; t(&#39;User account&#39;),<br>
 &nbsp; &nbsp; &nbsp;&#39;callback&#39; =&gt; &#39;drupal_get_form&#39;, &#39;callback arguments&#39; =&gt;<br>
array(&#39;user_login&#39;),<br>
 &nbsp; &nbsp; &nbsp;&#39;access&#39; =&gt; !$user-&gt;uid, &#39;type&#39; =&gt; MENU_CALLBACK);<br>
<br>
 &nbsp; &nbsp;$items[] = array(&#39;path&#39; =&gt; &#39;user/autocomplete&#39;, &#39;title&#39; =&gt; t(&#39;User<br>
autocomplete&#39;),<br>
 &nbsp; &nbsp; &nbsp;&#39;callback&#39; =&gt; &#39;user_autocomplete&#39;, &#39;access&#39; =&gt; $view_access,<br>
&#39;type&#39; =&gt; MENU_CALLBACK);<br>
 &nbsp; &nbsp;... Bunch of code ommitted....<br>
<br>
 &nbsp;} else {<br>
 &nbsp; &nbsp;... Some code ommitted.<br>
 &nbsp; &nbsp; &nbsp;if ($user !== FALSE) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp;// Always let a user view their own account<br>
 &nbsp; &nbsp; &nbsp; &nbsp;$view_access |= $user-&gt;uid == arg(1);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;// Only admins can view blocked accounts<br>
 &nbsp; &nbsp; &nbsp; &nbsp;$view_access &amp;= $account-&gt;status || $admin_access;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;$items[] = array(&#39;path&#39; =&gt; &#39;user/&#39;. arg(1), &#39;title&#39; =&gt;<br>
t(&#39;User&#39;),<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;type&#39; =&gt; MENU_CALLBACK, &#39;callback&#39; =&gt; &#39;user_view&#39;,<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;callback arguments&#39; =&gt; array(arg(1)), &#39;access&#39; =&gt;<br>
$view_access);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;$items[] = array(&#39;path&#39; =&gt; &#39;user/&#39;. arg(1) .&#39;/view&#39;, &#39;title&#39; =&gt;<br>
t(&#39;View&#39;),<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;access&#39; =&gt; $view_access, &#39;type&#39; =&gt; MENU_DEFAULT_LOCAL_TASK,<br>
&#39;weight&#39; =&gt; -10);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;$items[] = array(&#39;path&#39; =&gt; &#39;user/&#39;. arg(1) .&#39;/edit&#39;, &#39;title&#39; =&gt;<br>
t(&#39;Edit&#39;),<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;callback&#39; =&gt; &#39;drupal_get_form&#39;, &#39;callback arguments&#39; =&gt;<br>
array(&#39;user_edit&#39;),<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;access&#39; =&gt; $admin_access || $user-&gt;uid == arg(1), &#39;type&#39; =&gt;<br>
MENU_LOCAL_TASK);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;$items[] = array(&#39;path&#39; =&gt; &#39;user/&#39;. arg(1) .&#39;/delete&#39;, &#39;title&#39;<br>
=&gt; t(&#39;Delete&#39;),<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;callback&#39; =&gt; &#39;user_edit&#39;, &#39;access&#39; =&gt; $admin_access,<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;type&#39; =&gt; MENU_CALLBACK);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;if (arg(2) == &#39;edit&#39;) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (($categories = _user_categories($account)) &amp;&amp;<br>
(count($categories) &gt; 1)) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foreach ($categories as $key =&gt; $category) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$items[] = array(<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;path&#39; =&gt; &#39;user/&#39;. arg(1) .&#39;/edit/&#39;. $category[&#39;name&#39;],<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;title&#39; =&gt; $category[&#39;title&#39;],<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;type&#39; =&gt; $category[&#39;name&#39;] == &#39;account&#39; ?<br>
MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;weight&#39; =&gt; $category[&#39;weight&#39;],<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;access&#39; =&gt; ($admin_access || $user-&gt;uid == arg(1)));<br>
<div class="Ih2E3d"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
 &nbsp; &nbsp; &nbsp;}<br>
 &nbsp; &nbsp;}<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 &lt;<a href="mailto:florent.jousseaume@makina-corpus.com">florent.jousseaume@makina-corpus.com</a>&gt; wrote:<br>
<br>
&gt; For your example, this is not a switch, but 2 modules with differents<br>
&gt; ACL. The block &#39;login&#39; is displayed for &#39;Anonymous&#39; and the menu is<br>
&gt; displayed for &#39;Authenticated user&#39; (block Navigation).<br>
&gt;<br>
&gt; For the element&#39;s visibility in the menu, this is with the user_access<br>
<br>
&gt; method defined in the function &#39;hook_menu&#39; for each module.<br>
<br>
It looks a bit hakish.<br>
And I still can&#39;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&#39;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&#39;t yet understand the magic that make -My account appear in the<br>
Menu admin pages as locked. I still haven&#39;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&#39;d expect that if I build up a $items hierarchy I could build up a menu<br>
from the &quot;admin&quot; 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&#39;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&#39;t seen any tutorial, handbook... on any of the menu_ family<br>
of function.<br>
There is nothing on &quot;Pro Drupal development&quot; 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>