You are here

function variable_get_child in Variable 7

Same name and namespace in other branches
  1. 7.2 variable.module \variable_get_child()

Get variable child element from multiple variable

Parameters

$parent: Parent variable

$key: Key of the children variable (not the full name, just the piece of string that makes the difference)

Related topics

1 call to variable_get_child()
node_variable_type_subform in includes/node.variable.inc
Build subform for variables for node type

File

./variable.module, line 133
Variable API module

Code

function variable_get_child($parent, $key, $options = array()) {
  $variable = variable_build($parent, $options);
  $name = preg_replace('/\\[\\w+\\]/', $key, $variable['name']);
  $child = $variable['children'][$name];

  // Replace title and description
  foreach (array(
    'title',
    'description',
  ) as $property) {
    if (isset($variable[$property])) {
      $child[$property] = $variable[$property];
    }
  }
  return $child;
}