Similar as #769136: Taxonomy depth as field,
but for Taxonomy Views.

Comments

kenorb’s picture

Based on mavimo patch #70 from #769136: Taxonomy depth as field, definition of fields:

--- views_handler_field_taxonomy.inc	(revision 4)
+++ views_handler_field_taxonomy.inc	(working copy)
@@ -21,6 +21,8 @@
   function option_definition() {
     $options = parent::option_definition();
     $options['link_to_taxonomy'] = array('default' => FALSE);
+    $options['limit_depth'] = array('default' => FALSE);
+    $options['limit_depth_value'] = array('default' =>  array());
     return $options;
   }
 
@@ -35,6 +37,23 @@
       '#type' => 'checkbox',
       '#default_value' => !empty($this->options['link_to_taxonomy']),
     );
+
+    $form['limit_depth'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Limit terms by depth'),
+      '#default_value' => $this->options['limit_depth'],
+    );
+
+    $form['limit_depth_value'] = array(
+      '#prefix' => '<div><div id="edit-options-limit-depth-value">',
+      '#suffix' => '</div></div>',
+      '#type' => 'checkboxes',
+      '#title' => t('Display term with depth'),
+      '#options' => array_combine(range(1, 10), range(1, 10)),
+      '#default_value' => $this->options['limit_depth_value'],
+      '#process' => array('expand_checkboxes', 'views_process_dependency'),
+      '#dependency' => array('edit-options-limit-depth' => array(TRUE)),
+    );
   }
 
   /**
@@ -54,6 +73,10 @@
     return $data;
   }
 
+   function pre_render($values) {
+     /* TODO */
+   }
+
   function render($values) {
     $value = $this->get_value($values);
     return $this->render_link($this->sanitize_value($value), $values);

I'm not sure how pre_render should looks like.

kenorb’s picture