All pastes #575694 Raw Edit

Something

public text v1 · immutable
·published 2007-06-19 04:59 UTC
rendered paste body
  if ($view->name == 'directory_shops') {
    // Get all the children of "Shopping (tid 147)" and put the names in a simple array. 
    // This is the query from taxonomy_get_children(). Not using the function because
    // the array it returns is too complex for in_array() later on.
    $result = db_query(db_rewrite_sql('SELECT t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.tid = t.tid WHERE parent = %d ORDER BY weight, name', 't', 'tid'), 147);
    $keepers = array();
    while ($term = db_fetch_object($result)) {
      array_push($keepers, $term->name);
    } 
    
    // Get the directory category options that are in the select box
    $options = $form['filter1']['#options'];
 
    // Go through each option in the select box and unset it if it's not a in our list of keeper terms
    foreach ($options as $option => $text) {
      $values = array_values($options[$option]->option);
      $termname = str_replace("-","",$values[0]);
      if (!in_array($termname, $keepers)) {
          unset($options[$option]);
        }
      }
    
    // Replace the options in the select box with the cleaned up version
    $form['filter1']['#options'] = $options;
  }