#629756 by bangpound: Added CCK text and number conditions using content_allowed_valu...
authorSteven Jones
Tue, 20 Apr 2010 23:27:29 +0000 (23:27 +0000)
committerSteven Jones
Tue, 20 Apr 2010 23:27:29 +0000 (23:27 +0000)
context_contrib/context_contrib.module

index 95dc4c9..1de5681 100644 (file)
@@ -32,6 +32,21 @@ function context_contrib_context_conditions() {
     );
   }
 
+
+  // CCK
+  if (module_exists('content')) {
+    foreach (content_fields() as $field) {
+      if ($options = content_allowed_values($field)) {
+        $items[$field['field_name']] = array(
+          '#title' => $field['widget']['label'],
+          '#type' => 'checkboxes',
+          '#options' => $options,
+          '#description' => filter_xss_admin($field['widget']['description']),
+        );
+      }
+    }
+  }
+
   return $items;
 }
 
@@ -64,6 +79,17 @@ function context_contrib_nodeapi(&$node, $op, $teaser, $page) {
         context_set_by_condition('nodequeue', $qid->qid);
       }
     }
+
+    // Implementation of context for CCK.
+    if (module_exists('content')) {
+      foreach (content_fields() as $field) {
+        if (isset($node->$field['field_name']) && $options = content_allowed_values($field)) {
+          foreach ($node->$field['field_name'] as $item) {
+            context_set_by_condition($field['field_name'], $item['value']);
+          }
+        }
+      }
+    }
   }
 }