Navigation Block
tmq - December 28, 2003 - 16:54
Correct me if I'm wrong, but it seems that there has been a change in the behavior of the Navigation block. I've always had it turned off, since I don't want it on my page-- it's easier to create manual links. But having upgraded to 431, it appears that the administration menu will not appear without it. Previously, I could just go to mysite.com/user and login, whereupon an admin menu would appear in my left column. In other words, disabling the Navigation block also disbles the admin menu. Odd. Undesirable. Has this been changed on purpose, or am I just overlooking something?

Create a Custom Navigation Block
I don't want anonymous users to have a navigation block and I'm the onyl one who logs into my site for now, so (following someone elses tip, not sure who, this is not my idea, but theirs) I added a custom block that will only show for those who are logged in.
global $user;
if ($user->uid) {
if ($menu = menu_tree()) {
print $menu ;
}
}
Add that as a PHP block and the navigation will show up only if you are logged in and if you aren't it won't show up at all. That's what I use to access the administration menu, I ignore the other links such as my blog and create content as I have links to those on a toolbar in my browser.
What file did you insert that
What file did you insert that code into?
no insert
You go to "admin/configuration/blocks/add new block" and you create a new php block with that script as body.
Drupal makes it simple :p
Thanks - just what I needed!
The only thing missing was the border generating code which I created but can't copy paste here for some reason (getting eaten by the pre-processor or something).
In essence, your code generates an html list. By doing a view source on a page with a normal block I copy/pasted the table and class tags to go around it and added it to the block.
It works great! Thanks again!!
Border HTML
To format the menu insert the DIV and UL around your php.
<?phpglobal $user;
if ($user->uid) {
if ($menu = menu_tree()) {
echo "<div class=\"menu\">";
echo "<ul>";
print $menu ;
echo "</ul>";
echo "</div>";
}
}
?>
I know this thread is old, bu
I know this thread is old, but I thought I'd mention my experience with 4.4.0, since others might be searching for this issue like I did.
The code above didn't work for me; the "print" statement outputs the html before anything else is outputted, so the menu appears at the top of the page, outside even the starting html tag! I'm assuming this is new behavior in how custom blocks work in 4.4.0, but I have no clue. After poking through the modules, I discovered changing the line to a "return" statement fixed it.
global $user;
if ($user->uid) {
if ($menu = menu_tree()) {
return $menu;
}
}
Hope this helps someone.
error
i try to do this on drupal 4.5.0 and get
Fatal error: Call to undefined function: menu_tree() in /var/www/includes/common.inc(1884) : eval()'d code on line 6
niice. thanks
niice. thanks
What do you mean by....
What do you mean by "it's easier to create manual links". I'm just starting with Drupal and I'm unsure where to start. Using the Marvin theme I see the items I've added on the LHS and at the top(ish) a box with my login and "create content", "recent posts", etc. Is this a Nav block? If I go (4.3.2) Administer -> Configuration -> Blocks --> I see the four blocks (incl Navigation. Where do I go to edit/change blocks? How do I place them on a page, and how do I make that page *visible*?
I'm probably asking the wrong questions. The answers are probably "It doesn't work like that". I'm still on the steep part of the learning curve!
Cheers,
Cliff
Alternative way of hiding navigation menu
Goal:
Admin should be able to change settings
Users should never be able to see the admin menu
Steps:
Check that nobody except admins are allowed to view admin pages
Add this to the navigation block's path
"(^drupal/admin/.*|^drupal/admin$)"Change the drupal part to what ever directory you have installed drupal in to
this works great
also, dont forget that if drupal is installed to your webserver root, its just going to look like this:
"(^admin/.*|^admin$)"not working for me
when I do this, all I get showing up is the code itself in the block... ideas why this isn't working? I know it was working before I had to reinstall drupal. I'm using 4.5
tried all
Just wanted to mention that I have tried all the helpful code within the forums and it still doesn't seem to work for me... ideas??
no ideas?
anyone have any ideas why this is doing this now? I had to reinstall drupal completely (long story there) before I was able to use the last suggestion for hiding the login area unless logged in, but now I can't ... it won't recognize any of the above code. I'm using drual 4.5 and bluemarine for template.
ideas?? anyone??
use the menu module
An easy, non-php way to disable this default block is to turn on the menu module, and go to admin-->menu, and disable all of the items that appear under this block. Once it is an empty block, it won't display anymore.