By jayboodhun on
For some time i have been trying to figure out how to make certain blocks visible within certain og_groups , within certain content types and withing specific nodes.
I have tried og_group_visibility but this did not solve the problem.
So what i did the following :
Insert this in you index.php file after the Drupal Bootstrap
$group = $_SESSION['group'];
$_GET['group']=$group;
Then go to your Block configuration and add the following with the PHP option selected:
<?php
$match = FALSE;
// Insert Content types here
$types = array(
'forum' => 1,
'for_sale'=>1,
);
// Insert URLS here
$uris = array(
'/forums' => 1,
'/marketplace' =>1,
'/business-listing/284/29/&gid=284'=>1,
);
//Do not Edit
$group = $_GET['group'];
// Insert Group ID here
if($group=='284'
OR $group=='90'
) {
// Do not Edit Below
if ((arg(0) == 'node') && is_numeric(arg(1))) {
$node = node_load(arg(1));
$match = isset($types[$node->type]);
}
$match |= isset($uris[request_uri()]);
}
return $match;
?>
Hope this helps anybody. This will be particularly useful if you have advertisements to display in blocks you have to play around with visibility.
Comments
I just came across this old
I just came across this old post while searching for block visibility php snippets. I was curious if this still applies to drupal v6?