CVS edit link for whitie1979

I created a module for a recent Drupal project as I couldn't find an existing module that did precisely what I needed to accomplish.

I took all my project-specific code out of it and made it more generic to fit any Drupal 6 install. I thought it could be useful to others.

It is called Taxonomy Search and provides a dynamically updated (ajax) search form for Taxonomy hierarchies.

CommentFileSizeAuthor
#1 taxonomy_search.zip12.84 KBjschulz-1

Comments

jschulz-1’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new12.84 KB

Module that creates a dynamically updates taxonomy search form.

avpaderno’s picture

Status: Needs review » Needs work
Issue tags: +Module review

Hello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review your code, pointing out what needs to be changed.

As per http://drupal.org/cvs-application/requirements, the motivation message should be expanded to contain more details about the features of the proposed module, and it should include also a comparison with the existing solutions.

jschulz-1’s picture

My motivation for this module was that I needed the ability to combine taxonomy terms to search for nodes. I needed the form to re-draw after each selection the user makes in the form (e.g. if they select "orange" only criteria that combine with orange will be shown). This prevents any searches that don't have matching nodes (empty search results).

I used Blocks for the form display and Views for the search results, rather than recreating a bunch of functionality. I also used jQuery for the ajax implementation.

I looked at a number of existing modules before starting this one. I couldn't find one that updated the search form dynamically. Taxonomy Browser http://drupal.org/project/taxonomy_browser seemed to the closest, but again, did not provide a dynamically updated search form.

Thanks for considering this!

-Jason

avpaderno’s picture

Status: Needs work » Needs review
avpaderno’s picture

Status: Needs review » Needs work
  1.     // the ajax URL
        $items['process-taxonomy-form'] = array(
          'title' => 'Process Taxonomy Form',
          'page callback' => 'taxonomy_search_process_taxonomy_form',
          'access arguments' => array('access content'),
          'type' => MENU_CALLBACK,
         );
    

    Strings used in the user interface should be in sentence case.

  2.      if (count($vocabularies) != 0) {
            $term_vocab_results = db_query("SELECT tn.tid, v.name, td.vid, td.name, tn.nid, v.weight FROM term_node tn, term_data td, vocabulary v WHERE nid IN (%s) AND td.vid IN (%s) AND td.tid = tn.tid AND td.vid = v.vid ORDER BY v.weight, v.name", implode(',', $nids_array), implode(',', $vocabularies));
         }
         else {  
            $term_vocab_results = db_query("SELECT tn.tid, v.name, td.vid, td.name, tn.nid, v.weight FROM term_node tn, term_data td, vocabulary v WHERE nid IN (%s) AND td.tid = tn.tid AND td.vid = v.vid ORDER BY v.weight, v.name", implode(',', $nids_array));
         }
    

    The code should use drupal_placeholders().

  3. function taxonomy_search_form_submit($form, &$form_state) {
      
        // we will build a string of tids in the format 11+4+3+5
        $tids = '';
        
        foreach ($form_state['values'] as $key => $value) {
           // the array keys we want will be vids, so numeric
           if (is_numeric($key)) {
              foreach ($value as $tid) {
                 // if the value is 0, it was not selected on the form
                 if ($tid != 0) {
                    $tids .= $tid . ','; 
                 }
              }
           }
        }
        
        // remove the final + symbol
        if ($tids != '') {
          $tids = substr($tids, 0, -1);
        }
        $tids = str_replace('%252F', '', $tids);
    
        // taxonomy-search-results is a view with a multiple value tid argument
        $search_results_path = variable_get('taxonomy_search_results_path', 'taxonomy-search-results');
        drupal_goto($search_results_path . '/' . $tids);
    }
    

    Submission functions don't use drupal_goto().

  4.   $tids = substr($tids, 0, -1);
    

    See http://drupal.org/coding-standards to understand how a module should be written. In particular see the part about the Unicode functions a module should use.

  5. Doesn't Views use a specific file where the module can define its default views?
  6.   watchdog('Taxonomy Search', 'Taxonomy Search module uninstalled by @user.', array('@user' => $user->name));
      drupal_set_message(t('The Taxonomy Search module has been uninstalled.'), 'status');
    

    Is there any need to print that message in the log? Other modules (including the core ones) don't do that.

avpaderno’s picture

Status: Needs work » Closed (won't fix)

There have not been replies in the past week. I am marking this application as won't fix.

avpaderno’s picture

Component: Miscellaneous » new project application
Issue summary: View changes

Please read the following links as this is very important information about CVS applications.

Drupal.org has moved from CVS to Git! This is a very significant change for the Drupal community and for these applications. Please read Migrating from CVS Applications to (Git) Full Project Applications and Applying for permission to opt into security advisory coverage on how this affects and benefits you and the application process. In short, every user has now the permissions necessary to create new projects, but they need to apply for opt into security advisory coverage. Without applying, the projects will have a warning on projects that says:

This project is not covered by Drupal’s security advisory policy.