--- menutrails.module-orig	2011-02-14 00:44:31.000000000 -0800
+++ menutrails.module	2011-02-14 03:26:10.000000000 -0800
@@ -134,6 +134,24 @@ function menutrails_node_location($node)
         }
       }
     }
+    // CCK support
+    // Row format: field_name[index]=
+    if (module_exists('content')) {
+	    if(arg(0) == 'node' && is_numeric(arg(1))) {
+		    $cck_valuesets = variable_get('menutrails_cck_valuesets', FALSE);
+		    if($cck_valuesets) {
+			    $cck_valuesets = preg_replace('/[ =]+/', '', trim($cck_valuesets));
+			    foreach(explode("\n", $cck_valuesets) as $valueset) {
+				    $parts = preg_split('/[\[\]|]+/', $valueset);
+				    if ($node->{$parts[0]}) {
+			        if ($node->{$parts[0]}[$parts[1]]['value'] == $parts[2]) {
+			          $href = trim($parts[3]);
+			        }
+				    }
+			    }
+		    }
+	    }
+    }
   }
   else {
     // We may want to do some breadcrumbing.
@@ -330,6 +348,23 @@ function menutrails_menutrails_settings(
       '#description' => t('If a specific group node has an assigned menu item, use this as the trail for nodes which have that group as an audience. If present, this will override all other group settings.'),
     );
   }
+  // CCK support
+  if (module_exists('content')) {
+    $form['menutrails_cck'] = array(
+      '#type' => 'fieldset',
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+      '#title' => t('CCK ( Advanced )'),
+      '#description' => t('Settings for nodes with CCK values.'),
+    );
+    $form['menutrails_cck']['menutrails_cck_valuesets'] = array(
+      '#type' => 'textarea',
+      '#rows' => 5,
+      '#title' => t('CCK valueset'),
+      '#default_value' => variable_get('menutrails_cck_valuesets', FALSE),
+      '#description' => t('Set CCK field names and values to match menu paths. One value set per row in this format (field[index]=value|path). Example: "field_featured[0]=yes|stories/featured" will set any node page with the field \'field_featured\' where its only value equals \'yes\' to set a menu item with the path of \'stories/featured\' to be active as the node\'s parent. Keep in mind when specifing the link paths that you don\'t include your site\' base path, even if it equals \'/\'.'),
+    );
+  }
   return $form;
 }
 
