0

I am trying to turn off a block in drupal using existing code.

<?php
$node = node_load(arg(1));
$type = $node->type;

if(substr($_SERVER["REQUEST_URI"], 0, 13) == '/our-people')
{
return TRUE;
}
else
{
    return in_array($type,array('3_column_interior_page', '3_column_faculty_bio_page'));
}
?>

I wanted to add a page that will not show the block...

<?php
$node = node_load(arg(1));
$type = $node->type;

if(substr($_SERVER["REQUEST_URI"], 0, 13) == '/our-people')
{
return TRUE;
}
// new code here - I don't want this block to show up on the info sessions page.
elseif ($_SERVER["REQUEST_URI"], 0, 13) == '/information-sessions'
{
return FALSE;
}
// end new code
elseif
{
    return in_array($type,array('3_column_interior_page', '3_column_faculty_bio_page'));
}
?>

However it won't work. Being mostly a beginner, I am not sure how else to write it out.Any thoughts or a direction will help.

Thanks
Tim

4
Contributors
5
Replies
7
Views
4 Years
Discussion Span
Last Post by timwhelan
0

Hey,

Try this:

<?php
  $node = node_load(arg(1));
  $type = $node->type;

  if(substr($_SERVER["REQUEST_URI"], 0, 13) == '/our-people')
  {
     return true;
  }else if(substr($_SERVER["REQUEST_URI"], 0, 13)) {
     return false;
}else{
  return in_array($type, array('3_column_interior_page', '3_column_faculty_bio_page'));
}
0

You missed the substr function in your elseif:

if(substr($_SERVER["REQUEST_URI"], 0, 13) == '/our-people')
{
  return TRUE;
}
elseif (substr($_SERVER["REQUEST_URI"], 0, 21) == '/information-sessions')
{
  return FALSE;
}
else
{
  return in_array($type,array('3_column_interior_page', '3_column_faculty_bio_page'));
}
0

Okay, I figurede it out.

    <?php
    $node = node_load(arg(1));
    $type = $node->type;

    if(substr($_SERVER["REQUEST_URI"], 0, 21) == '/information-sessions')
    {
    return true;
    }
    elseif(substr($_SERVER["REQUEST_URI"], 0, 13) == '/our-people')
    {
    return true;
    } else {
    return in_array($type, array('3_column_interior_page', '3_column_faculty_bio_page'));
    }
    ?>

The False one needed to be first.

Peace
Tim

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.