function views_plugin_style_lineage_nested::render_nesting in Taxonomy Lineage 7
Same name and namespace in other branches
- 6 views_plugin_style_lineage_nested.inc \views_plugin_style_lineage_nested::render_nesting()
1 call to views_plugin_style_lineage_nested::render_nesting()
- views_plugin_style_lineage_nested::render in plugins/
views_plugin_style_lineage_nested.inc - Render the display in this style.
File
- plugins/
views_plugin_style_lineage_nested.inc, line 180 - Views style plugin that allows a view to be rendered as a nested list, based on Lineage's term hierarchy.
Class
- views_plugin_style_lineage_nested
- Implements views_plugin_style.
Code
function render_nesting($records, $rendered, $nesting_field = '', $term_name = FALSE) {
$nested_sets = array();
if (isset($this->view->field[$nesting_field])) {
$field_alias = $this->view->field[$nesting_field]->field_alias;
}
if ($field_alias) {
foreach ($records as $index => $row) {
$nesting = '';
// @todo Avoid using eval().
$lineage = $row->{$field_alias};
// If a filter term was passed, remove the lineage before the term.
if ($term_name) {
$lineage = strstr($lineage, $term_name);
if ($lineage) {
$lineage = substr($lineage, strlen($term_name) + 1);
// +1 for \n
}
}
// Strip weights from the lineage, if any.
if ($lineage) {
$lineage = explode("\n", $lineage);
foreach ($lineage as $key => $value) {
if ($value) {
$lineage[$key] = lineage_strip_weight($value);
}
}
$lineage = implode("\n", $lineage);
}
// Add the row to the array.
$eval = "\$nested_sets" . "['" . str_replace("\n", "']['", addslashes($lineage) . $index) . "']" . " = \$rendered[\$index];";
eval($eval);
}
}
else {
// Create a single group with an empty grouping field.
$nested_sets[''] = $records;
}
return $nested_sets;
}