Skip to content

Instantly share code, notes, and snippets.

@karlazz
Last active December 19, 2015 21:49
Show Gist options
  • Save karlazz/6023009 to your computer and use it in GitHub Desktop.
Save karlazz/6023009 to your computer and use it in GitHub Desktop.
Drupal 7: Views PHP filter to select items allocated into two groups, randomly designate group to select
// FILTER: GLOBAL PHP
// SETUP CODE
global $randvalforslides;
$randvalforslides=rand(1,2);
// FILTER CODE ---------------------------------------------
$node = node_load($row->nid);
$fhg = $node->field_homepage_group;
$fhg1=$fhg['und'][0]['value'];
global $randvalforslides;
if ( $fhg1 != $randvalforslides ) return TRUE; else return FALSE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment