0

I am trying to do a check for if some node contains an input element of type = hidden and with value = 'something'. If this is the case, some specific template should be used for the template.

I am trying to do this check in template.php using the template_preprocess_node() method where I have access to the $vars ($vars['node']) variable. However the only solution I can come up with is to loop through $vars['node']->webform['components'] and to check for the input type and after that the value.

However I dont find this approach elegant, what are my options?

0

The relationship between nodes and webform components is maintained in the webform_component table so you should be able to get the data directly from there:

$sql = "
  SELECT COUNT(*) 
  FROM {webform_component} 
  WHERE nid = %d 
  AND value = '%s'
  AND type = 'hidden'";

$args = array($vars['node']->nid, $field_value);

$count = db_result(db_query($sql, $args));

if ($count > 1) {
  // The webform has a hidden field with the correct value
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy