By geddon on
I'm attempting to hide the navigation block on a particular page while using the "signed in user check" code snippet that I pulled from the message boards. What I'm looking to achieve is as follows:
<?php
global $user;
if ($user->uid){
return TRUE;
} elseif ($page->places) {
return FALSE;
} else {
return FALSE;
}
?>
The above elseif statement is based on my weak understanding of PHP, but has no effect on the block. I've also tried using $nid->14 to hide the block on this same page with no results.
Comments
Hiding BLOCKS on Pages
Typed the wrong subject line!
I think...
If I understand what you're trying to do, I think this might be what you're after (although haven't tried it - so be careful!):
This should (I hope!) show the block on all pages when logged in. It'll hide the block for anonymous users when looking at node 14 (ie. yoursite.com/node/14 ).
I'd suggest building up your PHP gradually. Start with the easy bit:
...will hide the block for all anonymous users (if this hides your login box - don't worry, just visit yoursite.com/user/login to login and fix it!). Alternatively,
...will (I think!) hide the block on node 14, but show it on all the others.
My 2 pence worth, I hope that gets you on the right track...?
Looks Right..
..but the block displays on node 14 regardless.
I tried the third snippet to see if this hid the block on node 14 without any success.
To clarify a bit more, I'm hoping to hide a particular block on node 14 regardless of the user's sign-on status -- just to get a bit more room on a map page. The other blocks are being hidden through the Admin panel but hiding the Navigation block requires a bit more effort.
---
in administer -> blocks
can't one just put in the visibility settings area node/14 and switch the visibility settings to show on all pages except ? Thus disallowing the navigation menu on node/14 ?
This works, but..
The navigation block tends to show up when the user is signed off IF unregistered users are allowed to view content. This is why I used the bit of code above to hide the navigation block when users are signed off.
As I said previously, this complicates the issue when attempting to hide the navigation block regardless of them being signed on/off for one page in particular.
Reorder your logic
I don't know what you mean that the Navigation block requires more effort to hide it from the Admin panel.
But I think your logic was slightly flawed because it was checking that the user had an id first and returning a TRUE right away.
Try this:
One Step Closer
The above snippet works when a user is signed off and viewing node/14 -- but unfortunately when a user is signed in the block still appears on node/14.
In short English: If the node is 14, do not show the block. If the user is signed in and the node is NOT 14, then show the block. Otherwise, don't show the block.
How about: <?phpglobal
How about:
--
best regards
Ray
----------------------------------------------------------
If you need a drupal developer contact me!