By rande03 on
I'm trying to hide a block if a user has a certain role or if a certain page is displayed. I've succeeded in the first task, but can't get the second to work using arg(). The designated page is a webform so arg(0) is 'content'. My php is as follows:
global $user;
if (in_array(certain role,$user->roles))
{
return FALSE;
}
elseif (arg(1)=='certain-page')
{
return FALSE;
}
else
{
return TRUE;
}
Hiding the block worked when it was by role alone, but using the arg() condition alone or with role condition doesn't work. I've seen several posts here about using arg() and it seems really straightforward, so what am I missing?
Comments
Combine your false returns
Problem seems to be arg()
thanks for a quick reply. The problem seems to be with arg(). If use it alone without the role condition, it doesn't work either:
just to simplify, I tried "if (arg(0) == 'content')", and still no go. it really seems to be the arg() call.
There are a couple of things
There are a couple of things to consider, pages have paths and paths can have aliases.
Paths are of the form 'node', 'node/123', 'node/123/edit', 'admin', etc.
The arg() function returns the parts of the un-aliased path.
In general terms for node based content your check would look something like
problem solved
Yes! going back to the un-aliased node gets the result I want. Thanks, nevets.
thanks!
thanks!