Community Documentation

Create ComboBox related to taxonomy and nodes trought PHP on blocks

Last updated August 9, 2010. Created by nhomar on August 9, 2010.
Log in to edit this page.

With this code you can:
-- Add two taxonomy comboboxes from diferent parents.
-- Add a combo box with the title of a list of nodes

The Objective:

Create an efect like this:
http://jquery.geronimo.com.ve/

To search with 3 criterias autofilling the combos

<?php

       
//First Combo
       
$vector2 = taxonomy_get_children(152, $vid, 'tid');
       
$output .= "<form name='SEARCHFORM' method='post' action=''><select id='child152' name='child152'>";
        foreach(
$vector2 as $c=>$v)
           
$output .= "<option value='".$c."'>".$v->name."</option>";
           
$output .= "</select>";
       
//Second Combo
       
$vector3 = taxonomy_get_children(153, $vid, 'tid');
       
$output2 .= "<select id='child153' name='child153'>";
        foreach(
$vector3 as $c=>$v)
           
$output2 .= "<option value='".$c."'>".$v->name."</option>";
           
$output2 .= "</select>";
       
//Third Combo
       
$taxo_id = 6;
       
$list_no = 10;
       
$term1 = 'CLUTCHES' ;
       
$term2 = 'G.M / CHEVROLET' ;
       
$term3 = 'G.M / CHEVROLET' ;
       
$term_count = 2;
       
$sql = "SELECT n.title , n.nid from {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid INNER JOIN {term_data} d ON d.tid = tn.tid WHERE d.name IN('$term1','$term2') GROUP BY n.title HAVING COUNT(*) = $term_count";
       
$output3 .= "
            <select id='tit_combo' name='tit_combo'>
        "
;
       
$result = db_query($sql);
        while (
$anode = db_fetch_object($result)) {
       
$output3 .= "<option value='".$anode->nid."'>".$anode->title."</option>";
        };
       
$output3 .= "</select>";
       
$bothcombos=$output."</br>".$output2."</br>".$output3."<br/> Hola Mundo";
        return
$bothcombos;
?>

Page status

About this page

Drupal version
Drupal 6.x
Audience
Developers and coders

Reference

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here