function theme_views_tree in Views tree 6.2
Same name and namespace in other branches
- 6 views_tree.module \theme_views_tree()
- 7.2 views_tree.module \theme_views_tree()
Theme function for the tree style plugin.
We need to do some weirdness that makes more sense as a theme function than as a template.
@link http://drupal.org/node/355919
File
- ./
views_tree.module, line 40
Code
function theme_views_tree($view, $options, $rows, $title) {
$result = $view->result;
$fields =& $view->field;
$options['main_field_property'] = $fields[$options['main_field']]->field_alias;
$options['parent_field_property'] = $fields[$options['parent_field']]->field_alias;
// Normalize the top level of records to all point to 0 as their parent
// We only have to do this once, so we do it here in the wrapping function.
$parents = array();
foreach ($result as $record) {
$parents[] = $record->{$options}['main_field_property'];
}
foreach ($result as $record) {
if (!in_array($record->{$options}['parent_field_property'], $parents)) {
$record->{$options}['parent_field_property'] = 0;
}
}
return $title . theme('views_tree_inner', $view, $options, $rows, $title, $result, 0);
}