How am I able to make a filter exposed in Viwes that the Parents of a taxonomy only shows?
And later another that only shows the children of the taxonomy selected in the previous one.

At the moment sample a list of all, that which returns her very long.

Example:

Taxonomy:
Topic A
-sub topic A1
-sub topic A2
Topic B
-sub topic B1
-sub topic B2

Filter Topic
Topic A
Topic B

Filter Sub Topic (if it is Topic A)
sub topic A1
sub topic A2

Comments

sylvaticus’s picture

I was gonna make the same request.. luckily I first searched ;-)

It exist the directory module, but not being a view it doesn't give it flexibility (eg filtering other dimensions)...

armand0’s picture

Ok. And if I only want the parents to be shown, how do I make it?
To make it outside of VIEWS the following code it is, But How do I modify the exposed filters to make it in VIEWS?


<?php
$output = drupal_get_form('Countries_dropdown_form', $form);
return $output;

function Countries_dropdown_form() {
// vocabulary to use
  $vid = 298;
// url parent term if exist
  $parent = arg(1);
// internal use
  $depth = -1;
// how depth search, 1parents, 2children, etc.
  $max_depth = 1;
// declare items array
  $items = array();
// set form name
  $formname = 'States';
// if no url arg, then set to cero.
  if (!is_numeric ($parent)) {
         $parent=0;
         $formname = 'Country';
      }
// get terms. If exist an URL parent get the children, if not get only the parents.
  $terms = taxonomy_get_tree($vid, $parent, $depth, $max_depth);
// use the terms, in this case show a list.
    $options[] = t('Seleccionar ' . $formname);
    //Populate array with url / name
        foreach ( $terms as $term ) {
            $options['/ubicacion/'.$term->tid.'/portada'] = $term->name;
        }
    //Build dropdown select
    //If we try to build OnChange directly it gets mangled, so put in array to confuse the forms api
    $form['category'] = array(
      '#type' => 'select',
      '#name' => $formname,
      '#id' => $formname,
      '#title' => '',
      '#default_value' => '',
      '#options' => $options,
      '#description' => '',
      '#multiple' => $multiple = FALSE,
      '#required' => $required = FALSE,
      '#attributes' => array('onChange' => 

"top.location.href=document.getElementById('$formname').options[document.getElementById('$formname').selectedIndex]

.value"),
    );
        return $form;
}
?>

Views something doesn't have as "$max_depth" of the previous code?.

Thank you

domesticat’s picture

Status: Active » Closed (fixed)

Performing a mass closing of all issues over 180 days old. Please reopen if needed.