Monday, September 24, 2012

Overview-approach to block visibility

As of Drupal 5.x you can specify what roles can see a block through the block admin UI, but using PHP still gives you extra flexibility.
If you are going to set visibility on a lot of blocks, see Block Page Visibility
Review of how the role visibility works in Drupal 5
  • If no role check boxes are checked, block is visible to all roles.
  • If "authenticated user" is checked, all logged in users will see the block, checking any of the other role boxes (other than anonymous user) is meaningless.
  • Checking anonymous users means that logged-in users, unless they belong to another role that is also checked, will not see the block.
Basics of setting visability via PHP:
  1. Go to administer >> access control and ensure “administer blocks “ and “use PHP for block visibility” are checked for your role.
  2. Go to administer >> blocks and find the block you want to set the visibility for.
  3. Click “configure” next to that block.
  4. Under the section entitled, “Page specific visibility settings”, click the radio button for “Show if the following PHP code returns TRUE”
  5. In the text box provided, enter whichever of the following snippets meets your needs: 
Read More

No comments:

Post a Comment

only show translated menu items into current language (Drupal 8)

function MY_THEME_preprocess_menu(&$variables) {   if ($variables['menu_name'] == 'brancott-header-menu') {    $langu...