Block on specific pages and node types I'm trying to make a block display on a specific page and inside a node type; I got this code from drupal.org, but I keep getting this error.



Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController-&gt;load() (line 178 of /home/content/45/6861545/html/includes/entity.inc).
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController-&gt;cacheGet() (line 354 of /home/content/45/6861545/html/includes/entity.inc).


This is the code I used.

$match = FALSE;
$types = array('middle_content' =&gt; 1);
if (arg(0) == 'node' &amp;&amp; is_numeric(arg(1))) {
  $nid = arg(1);
  $node = node_load(array('nid' =&gt; $nid));
  $type = $node-&gt;type;
  if (isset($types[$type])) {
    $match = TRUE;
  }
}

if (substr($_SERVER["REQUEST_URI"], 0, 10) == '/test'){
  $match = TRUE;
}

if (substr($_SERVER["REQUEST_URI"], 0) == "/node/add/middle_content") {
  $match = TRUE;
}

return $match;
To actually fix that error, see my answer to a stackoverflow question.

However, in that case, your code can be simplified a lot using menu_get_object():

$types = array('middle_content' =&gt; 1);
if ($node = menu_get_object()) {
  if (isset($types[$node-&gt;type])) {
    return TRUE;
  }
}


And anyway, you should avoid PHP in blocks etc (See What are the downsides of using PHP Filter code in blocks, nodes, views-args, etc?), check out Context. It allows you to configure your blocks (among other things) for conditions exactly like this without having to write code. It is also much faster.