By Ceb on
The next question in development.
I want a block to show up on user profile pages only if the profile page belongs to the current user. So I have :
Created a mini-panel with elements such as 'private messages' and 'buddy list'.
I then configured the block to show only if php code returns true with the following code:
<?php
global $node;
global $user;
if ($node->uid == $user->uid) return TRUE;
else return FALSE;
?>
Last, I go to the user profile panels and insert the new mini-panel into the profile page. But alas, it seems no matter what it shows up on all profile pages, not just just my own. What I have I done wrong?
Comments
_
Couple of things--
-are you using the core profile module? core profile module does not produce nodes.
-i don't believe there is a global $node
usernodes
My core profile module is disabled and I am using the usernodes module. I had seen the 'global $node' used somewhere while lost on google so figured I'd give it a try as it made sense I'll look for other options.
_
I've never used usernodes, so I'm not 100% sure, but try something like:
<?phpglobal $user;return
http://api.drupal.org/api/function/arg/6
That code works beautifully
That code works beautifully if it is a block placed in a 'block location' and is filtering properly, but as mentioned in my other post, it is being ignored when imported into a panels page as a mini-panel.
Wrong Troubleshooting Direction
It would seem I may have had the right code in place 5 times already for all I know.
I also forgot to mention the use of the advanced profile kit, if it makes a difference.
BUT, the problem seems to be that by inserting a mini-panel into another panels page, the block visibility settings are being completely ignored.
The block at this moment says only to show if the php code returns true.... the current code is.
But still the block is showing up. So it seems it doesn't matter what code I use, it's being ignored.
Workaround
Well, for those of you who come here as a result of a search for something similar, the final workaround was to use the following code:
and use it as a block rather than inserting it into a panel. As, apparently the block visibility is ignored by panels and has been mentioned in a few places on the forums with what appears to be no resolve.
Figured this out if you'd
Figured this out if you'd still like to use panels.
I'm using Drupal 6, shouldn't be too much of a difference, if any.
Create a new block with the following code in the body:
You should now have a block that "obeys" block filters but can be used in panels.
Hi all. I come back to this
Hi all. I come back to this post so i can clarify some things. I created a block with the following custom code i found
I put this block in the user profile panel page i created. Now how can i combine the code from #comment-1761756 with the code i have in my block body in order it will be showed up only if the logged in user owns current profile?