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

Recommended Answers

All 5 Replies

change elseif in line 15 to else

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'));
}

Thank you for the input. Neither solution worked though.

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'));
}

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.