[support] block visibility based on role AND path

Steve Kessler skessler at denverdataman.com
Mon Oct 6 13:59:51 UTC 2008


Why does PHP need to be used. In the blocks settings you can determine
visibility for a specific roles as well as specific paths. 

 

For example you could say that only editors see an editing tool bar on all
pages content/* 

 

I may be missing what is going on here but this sounds similar than needing
to do PHP. 

 

Thanks,

Steve

 

Steve Kessler 

Denver DataMan 

303-587-4428 

Sign <http://www.denverdataman.com/content/enewsletter-signup>  up for the
Denver DataMan Free eNewsletter

 

From: bharani kumar [mailto:bharanikumariyerphp at gmail.com] 
Sent: Monday, October 06, 2008 7:34 AM
To: support at drupal.org; nick_young at ncsu.edu
Subject: Re: [support] block visibility based on role AND path

 

May  this is clue,

If you know  member id,  ,

Go to block  configure

select  " Show if the following PHP code returns TRUE (PHP-mode, experts
only). "

and write the code

global $user

$userid=$user->uid;
if($userid ==10 || $userid ==10  ){
     
return TRUE;

}
else{

return FALSE;
}



On Mon, Oct 6, 2008 at 6:19 PM, Nick Young <nick_young at ncsu.edu> wrote:

(Issue in Drupal 6)
I need a php snippet that allows me to display (or hide) a block based
on whether the user logged in is a member of a certain role, and that
they are browsing the site at a certain path. I am able to display a
block based on one of these things, but not both.

IE:
I can display a block if the user is a member of a role.
I can display a block at a certain path (<site>/node/path/x)

However, if i combine the two pieces of php code, then if one of them
returns true, the block shows. What i need is for it to check if the
path is TRUE, and then also check for the role membership. I have tested
the code externally to Drupal, to make sure the nested IF statements are
working properly, and they are. It's almost as if Drupal sees the first
TRUE, and then stops looking to see if there are multiple conditions to
check for as well.

Any ideas? Thanks in advance.

........................................................................
Nick Young
Outreach, Communications & Consulting
Office of Information Technology
North Carolina State University
Box 7109, Raleigh 27695
Ph. 919.513.2716 | E-Mail: nick_young at ncsu.edu <mailto:nick_young at ncsu.edu>
........................................................................



--
[ Drupal support list | http://lists.drupal.org/ ]

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20081006/2748cfc8/attachment.htm 


More information about the support mailing list