Shop By Brand /Manufacturer - Dropbox


For Drupal 5.x

How to Setup!

1) Where it says $vid=1;, replace the number 1 with the vocabulary ID number for the vocabulary you want to use to populate the drop-down with the terms in that vocabulary.

2) Optional: Where it says $options[] = t('List by ' . $formname);, replace List by with the word(s) you want at the beginning of the default text in the drop-down.

3) Where it says $options[''.$term->tid] = $term->name;, replace with the URL of your drupal website, or, leave only '/taxonomy/term/' to user relative path.

4) Put this PHP Code Snippet in a Block ---- Make sure you select PHP in the input format list for it to work.

= drupal_get_form('Brands_dropdown_form', $form);


Brands_dropdown_form() {
$vid=1; //change to your Vocabulary ID

$vocabulary = db_query("SELECT, td.tid FROM {term_data} td WHERE td.vid=%d ORDER BY", $vid);
// Initialize the country array
$options[] = t('List by ' . $formname);
//Populate array with url / name
while ($term = db_fetch_object($vocabulary)) {
$options['/taxonomy/term/'.$term->tid] = $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"),

You can also use a basic Listing with this PHP Code

= 1; /* <---- put correct vocabulary ID here */
$terms = taxonomy_get_tree($vid);
"<div class=\"item-list\">";
foreach (
$terms as $term ) {
$tcount = taxonomy_term_count_nodes($term->tid);
l($term->name." (".$tcount.")",'taxonomy/term/'.$term->tid, array('title' => $tcount." posts in ".$term->name)).
/* end foreach */
print "</ul>";
alien73's picture
Bug Finder
Joined: 11/10/2007
Juice: 450
Re: Shop By Brand /Manufacturer - Dropbox

If you want cleaner urls use this code snippet for the options above

$options['/taxonomy/term/'.$term->tid] = $term->name;

replace with

$options['' . str_replace(' ', '-', $term->name)] = $term->name;