Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.956 diff -u -r1.956 common.inc --- includes/common.inc 8 Aug 2009 20:52:32 -0000 1.956 +++ includes/common.inc 10 Aug 2009 08:34:48 -0000 @@ -3936,7 +3936,13 @@ // Call the element's #theme function if it is set. Then any children of the // element have to be rendered there. if (isset($elements['#theme'])) { - $elements['#children'] = theme($elements['#theme'], $elements); + $element = theme($elements['#theme'], $elements); + if (is_array($element)) { + $elements = $element; + } + else { + $elements['#children'] = $element; + } } // If #theme was not set and the element has children, render them now // using drupal_render_children(). @@ -3948,7 +3954,13 @@ // children. if (isset($elements['#theme_wrappers'])) { foreach ($elements['#theme_wrappers'] as $theme_wrapper) { - $elements['#children'] = theme($theme_wrapper, $elements); + $element = theme($theme_wrapper, $elements); + if (is_array($element)) { + $elements = $element; + } + else { + $elements['#children'] = $element; + } } } Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.503 diff -u -r1.503 theme.inc --- includes/theme.inc 4 Aug 2009 07:04:21 -0000 1.503 +++ includes/theme.inc 10 Aug 2009 08:34:50 -0000 @@ -687,6 +687,9 @@ function theme() { $args = func_get_args(); $hook = array_shift($args); + if (isset($args[0]) && is_array($args[0]) && isset($args[0]['#theme'])) { + $rendarable_array = $args[0]; + } static $hooks = NULL; if (!isset($hooks)) { @@ -728,7 +731,7 @@ // with a renderable array as the only argument (via drupal_render), then // we take the arguments from the properties of the renderable array. If // missing, use hook_theme() defaults. - if (isset($args[0]) && is_array($args[0]) && isset($args[0]['#theme']) && count($info['arguments']) > 1) { + if (isset($rendarable_array) && count($info['arguments']) > 1) { $new_args = array(); foreach ($info['arguments'] as $name => $default) { $new_args[] = isset($args[0]["#$name"]) ? $args[0]["#$name"] : $default; @@ -747,6 +750,9 @@ $count = 0; foreach ($info['arguments'] as $name => $default) { $variables[$name] = isset($args[$count]) ? $args[$count] : $default; + if (isset($rendarable_array) && $count === 0) { + $remember_name = $name; + } $count++; } } @@ -807,10 +813,19 @@ } } $output = $render_function($template_file, $variables); + if (isset($rendarable_array)) { + $rendarable_array = $variables[$remember_name]; + } } // restore path_to_theme() $theme_path = $temp; - return $output; + if (isset($rendarable_array)) { + $rendarable_array['#children'] = $output; + return $rendarable_array; + } + else { + return $output; + } } /**