All pastes #1663597 Raw Edit

Drupal Block Visibility Snippet

public text v1 · immutable
#1663597 ·published 2009-11-09 16:50 UTC
rendered paste body
/* code snippet for setting block visibility by both content type and url. This snippet is not tested*/
$make_block_visible = FALSE; //initializing the variable
/* determines whether its a node page, and if so, it will display block if node-type is 'blog' */
	if ((arg(0) == 'node') && is_numeric(arg(1)) && !(arg(2))) {
	  $thenode = node_load(arg(1));’
	  if ($thenode->type == 'blog') {
	    $make_block_visible = TRUE;
	  }
	}
  /* causes the block to show any time "blog" appears in the url */
	$url = request_uri();
	if (strpos($url, 'blog')) {
	  $make_block_visible = TRUE;
	}

	return $make_block_visible;
 
?>