By Marco Palmero on
I like how http://www.threadwatch.org setup their user system...
Their login box is in the top right corner and when you login - the block is then replaced by the "Navigation" block - the block where the user's username is printed out and their relevant account settings links are displayed.
I tried to look at other solutions but they don't quite match the way the site above does it
http://drupal.org/node/16758
Which has a link to a patch that doesn't work and this:
<?php
global $user;
if($user->uid){
//Print Navigation menu
$sna = module_invoke('menu', 'block', 'view', 1);
print $sna['content'];
}
?> Then disable the original Navigation Block.
BUT even when the block is invisible - the title shows up.
Any ideas?
Comments
Put the navigation and login
Put the navigation and login block on right.
When youre not logged in, the navigation block will be hidden. Once youre logged in, the login block will be hidden and the navigation block visible.
Thats it!
The Navigation block will
The Navigation block will still appear if there are links in the block that anonymous users have access to.
-- Merlin
[Point the finger: Assign Blame!]
[Read my writing: ehalseymiles.com]
-- Merlin
[Read my writing: ehalseymiles.com]
[Read my Coding blog: Angry Donuts]
The only reason I can think
The only reason I can think of for that box to show up even when it's invisible is if you have some extra whitespace or some such outside of your PHP tags that is getting printed. Make sure there is nothing before the <?php and nothing after the ?>.
-- Merlin
[Point the finger: Assign Blame!]
[Read my writing: ehalseymiles.com]
-- Merlin
[Read my writing: ehalseymiles.com]
[Read my Coding blog: Angry Donuts]
Okay solved
Thanks guys,
but this is how I solved it:
Simply disable absolutely everything until the block disappears for the anonymous user.
And when users log in - the block magically reappears with only user related admin links.
____________________________________________________________________________
Blog | Sydney News | Photography | Travel |Best Designed Drupal Websites
This worked except for the
This worked except for the custom item I added. I added a link to forum/3. The anonymous user doesn't have access to the forum, but the link still shows up. Any ideas why?
-Eric
Unfortunately, custom links
Unfortunately, custom links are always accessible to all. In order to add a menu item that actually checks access privileges, you'll need to create a custom module and use hook_menu().
-- Merlin
[Point the finger: Assign Blame!]
[Read my writing: ehalseymiles.com]
-- Merlin
[Read my writing: ehalseymiles.com]
[Read my Coding blog: Angry Donuts]
The answer is relatively simple
Go to
administer -> blocks -> navigation block -> configure
Select the option "show if the following code returns TRUE" and
put the following code in the block:
This means it won't show up unless you are logged in i.e. non-zero uid.
Cheers,
Mark
--
Mark Horner
Jabber/AIM/Yahoo/Gizmo/Skype/Google: marknewlyn
Co-author:
http://www.nongnu.org/fhsst
http://savannah.gnu.org/projects/fhsst
"Life is but a seg-fault away ...
Life received signal SIGSEGV, Segmentation fault.
0x42074d40 in
Not available
The method "show if the following code returns TRUE" is not possible on Drupal < 4.7.
Here's how to Show/Hide blocks for certain users and Show/Hide blocks for certain roles.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.
Oops
Sorry about that - I'll read the beginning of the thread next time :(
Mark
Geared up for 4.7 support
Well, you seem already geared up for 4.7 support, so when you see 4.7 in the right most corner of a post, fire away :-)
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.