taxonomy switch not support drupal v6.x :(

Comments

joel_guesclin’s picture

It will almost certainly support D6 when D6 settles down and I start thinking about converting my own sites! Unless something better comes up in the meantime.

luisfeng’s picture

Taxonomy Switch is very cool module, and very useful, waiting for the 6 version!

that0n3guy’s picture

I have a site that uses this module. It is one of the last modules (I use 37 modules) on my site to do an update. Most modules have a beta version by now.

Any time frame on this?

joel_guesclin’s picture

At the moment I am so overloaded that I will probably start thinking about this around January 2009. Sorry it is so long - if you want to try doing it yourself I would be glad to test a patch though.

momper’s picture

subscribing

Brigadier’s picture

subscribing

Brigadier’s picture

StatusFileSize
new9.59 KB

Not sure if this helps but I gave the latest release for D5 a quick run through Deadwood, made a minor tweak or two and made a patch. It gives me an error on $vid_from after selecting the vocabularies but it's possible there's an issue on my development site too. Anyway, hope this helps.

Brigadier’s picture

StatusFileSize
new17.87 KB
new430 bytes
new10.71 KB

Okay, I couldn't leave it alone. Besides the changes Deadwood made in the previous patch, I also had to change calls like

module_invoke('taxonomy', 'get_vocabulary', ... );

to

module_invoke('taxonomy', 'vocabulary_load', ...);

Apparently the name of the taxonomy module hook changed in Drupal 6. I don't know if any other module_invoke() calls need to change, but I made the module work for my site with the changes in the attached patch. Again, this patch is against the current Drupal 5 release version of the .module file (the .info file just needs a minor change to say it works with Drupal 6).

I've also attached the .info and .module file for people who want to try it out but don't know how to apply a patch but want to help test. (Don't use these on any data you care about.)

Oh, and there are some TODO comments in there that Deadwood made. I left them in because I don't know the correct way to fix them yet.

Kripsy’s picture

I've tested the patch and so far everything works fine.

momper’s picture

i tested with some taxonomies - no problems so far ...

caillou’s picture

subscribing

mean0dspt’s picture

thanks, this patch worked

joel_guesclin’s picture

Thanks very much for this - I will try it out and put up an official version as soon as possible

jordanka’s picture

can you pls explain how to test it? I have Drupal 6 site, and I need this module asap.

mean0dspt’s picture

-Download files from comment #8
-rename the two of them, removing .txt part from the end of the file (thus changing file extension to .module and .info)
-create new directory named "taxonomy_switch" at sites/all/modules and upload files there
-enable module in a usual way
-start using through new tab in admin -> taxonomy

jordanka’s picture

it works perfectly on my Drupal 6.9

Thanks.

rkdesantos’s picture

Version: 5.x-1.x-dev » master

I don't get the "classify" tab on v6.9.

luisfeng’s picture

I don't get it either....

avpaderno’s picture

Title: taxonomy switch not support drupal v6.x :( » Taxonomy Switch doesn't support Drupal v6.x
asb’s picture

subscribing

Greetings, -asb

joel_guesclin’s picture

Does your user have "administer taxonomy" permission? If not you will not see the tab

rkdesantos’s picture

I don't get the tab even running as user 1. I verified that the admin users have "administer taxonomy" permission and still no "classify" tab.

subir_ghosh’s picture

I don't get it on D6.12 either.

subir_ghosh’s picture

I think D6 itself has settled down quite well. The major set of modules like CCK, Views have settled down too. On the other hand, many D5 modules are no longer being worked on.

macrodesign’s picture

please help, i need to use taxonomy switch for 6.12 how can i do that, above comments are too tech-savvy. thanks

rkdesantos’s picture

@macrodesign: if you can't follow this discussion it is probably best that you do not attempt to use the "test" version for D6 in this thread. It is not even at the level of "beta" software at this stage and as such not safe to use unless you are sure of what you are doing and take necessary precautions (backups, etc.) Hopefully, the maintainer(s) of this module will see fit to move things along further soon and get a version out there that can be more widely tested and used.

macrodesign’s picture

Thanks RK, i will wait for a D6 release than.

petednz’s picture

Just used files available at #8 - all good so far (ie have been able to switch terms of VocabA to VocabB)

@macrodesign

If you are okay uploading a module, and you have a test site to try it on, all that is required AFAIK is to download the files from #8 - rename those files so they don't have .txt at end, ie

taxonomy_switch.info
taxonomy_switch.module

stick in a folder (for tidiness sake) upload folder to your site and enable (and give permissions if required) - worked for me

pretty much repeating what #15 said ;-)

macrodesign’s picture

Thanks peted, i will surely give it a try

joel_guesclin’s picture

For all those who want a true taxonomy switch in D6, can I suggest using Taxonomy Manager? See this post about Taxonomy Manager for details. I would be interested in feedback - if it works then I will deprecate taxonomy_switch.

mean0dspt’s picture

current stable version of Taxonomy Manager doesn't have such functionality yet. So it's way to early to deprecate Taxonomy Switch. We should at least wait for stable release. Then we should see if it'll be implemented for D5 Taxonomy Manager.

rkdesantos’s picture

I agree with mean0dspt.

damienmckenna’s picture

Could someone please explain what features are missing from Taxonomy_Manager to cover the needed features from Taxonomy_Switch? Thanks.

naught101’s picture

@DamienMcKenna: well, the "classify" tab is actually pretty cool. Possibly it could be made into a separate module, because it doesn't really fit in Taxonomy Manager...

The other main feature is now in taxonomy manager: #269341: Move term into other vocabulary.

asb’s picture

Hi,

actually the "classify" tab is a lifesaver for me on several D5 sites where - for whatever reason - the taxonomy fields disappeared from the node editing forms. I would really, really miss it - not only on those D5 sites.

Maybe Taxonomy manager could bundle the "classify" tab as an optional sub-module (if there's code that can be shared)?

Greetings, -asb

rkdesantos’s picture

I agree with asb. The classify tab is incredibly valuable.

kansaj’s picture

ok try this I thnik is working. Do mot forget to clear the cahe.

/* $Id: taxonomy_switch.module,v 1.7 2007/09/01 11:38:51 joelguesclin Exp $ */

/**
 * @file taxonomy_switch.module
 * This module allows you to move a term from one vocabulary to another, or to
 * reclassify a node
 */
/** 
 * Implementation of hook_menu: Define menu links.
 * 
 * @note See hook_menu for a description of parameters and return values.
 */
function taxonomy_switch_menu() {
      $items['node/%node/classify'] = array(
		'title' => t('Classify'),
		'type' => MENU_LOCAL_TASK,
        'access callback' => "taxonomy_switch_check_local_tasks",
		'access arguments' => array(1),
		'page callback' => 'taxonomy_switch_node',
        'page arguments' => array(1),		
		);
  return $items;
}

function taxonomy_switch_check_local_tasks($node) {
// we introduce a new accses rule
  return (user_access('taxonomy_switch_view')); 
}
function taxonomy_switch_node() {
global $user;
  $op = $_POST['op']; 
  $edit = $_POST;
//  arg(1) is the nid
  if ($op) {
    $node = module_invoke('node', 'load', arg(1));
    taxonomy_node_save($node, $edit['taxonomy']);
    if (module_exists('checkout')) {
      module_invoke('checkout', 'checkin', arg(1));
      }
    watchdog('content', '%type: reclassified %title.', array('%type' => $node->type, '%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));
    drupal_set_message(t('The document has been reclassified'));
    print theme('page', $output);
    return;
    }
  if (module_exists('checkout')) {
    $checkout_info = module_invoke('checkout', 'checkout', arg(1));
    if ($checkout_info->uid == $user->uid) {
	$checked_out = FALSE;
	}
    else {
	$checked_out = TRUE;
	}
    }
  else {
    $checked_out = FALSE;
    }
  if (!$checked_out) {
  $output = drupal_get_form('taxonomy_switch_classify_form');
	return $output;
	}
   else {
     module_invoke('checkout', 'message', $checkout_info);
     }

}

/* In Drupal 5, forms must be created in dedicated builder functions */
function taxonomy_switch_classify_form($form_values = NULL) {
  
	$form = array();
	$form['taxonomy']['#tree'] = TRUE;
	$node = module_invoke('node', 'load', arg(1));
	drupal_set_title(check_plain($node->title));
	  $node_vocabs = module_invoke('taxonomy', 'get_vocabularies', $node->type);
	  foreach ($node_vocabs as $i => $vid) {
	    $form['taxonomy'][$vid->vid] = module_invoke('taxonomy', 'form', $vid->vid);
	    $node_terms = taxonomy_node_get_terms_by_vocabulary($node, $vid->vid);
	    if ($vid->tags == 1) {
              $typed_string = array();
	      foreach($node_terms as $ix => $n_tid) {
		$typed_string[] .= $n_tid->name;
		}
              $form['taxonomy']['tags'][$vid->vid]['#title'] = $form['taxonomy'][$vid->vid]['#title'];
              $form['taxonomy']['tags'][$vid->vid]['#description'] = $form['taxonomy'][$vid->vid]['#description'];
	      $form['taxonomy']['tags'][$vid->vid]['#default_value'] = implode(', ', $typed_string);
	      $form['taxonomy']['tags'][$vid->vid]['#type'] = 'textfield';
	      $form['taxonomy']['tags'][$vid->vid]['#maxlength'] = 120;
	      $form['taxonomy']['tags'][$vid->vid]['#size'] = 60;
	      $form['taxonomy']['tags'][$vid->vid]['#autocomplete_path'] = 'taxonomy/autocomplete/'. $vid->vid;
              unset($form['taxonomy'][$vid->vid]);
	      }
	    else {
   	      $form['taxonomy'][$vid->vid]['#default_value'] = array_keys($node_terms);
   	      }
	    if ($vid->required) {
   	      $form['taxonomy'][$vid->vid]['#required'] = TRUE;
	      }
	  }
	$form[] = array(
	  '#type' => 'submit',
	  '#value' => t("Classify"),
	  );
//  $form['#redirect'] = FALSE;
  return $form;
}

rkdesantos’s picture

Is the content in #37 intended as a full replacement for the module code in #8 or as a patch to it?

kansaj’s picture

Depends on your wish you van use it as a standalone module, or as a patch. It works in both ways.
Cheers

joel_guesclin’s picture

I will try to find some time to test this. If it works ok for me then I will make it a standalone module to replace the present one, since the rest is handled by the Taxonomy Manager module

kansaj’s picture

Hi in case you are goiing to try it please use the code bellow. I forgot to include the function which declares the permission :)

/* $Id: taxonomy_switch.module,v 1.7 2007/09/01 11:38:51 joelguesclin Exp $ */

/**
* @file taxonomy_switch.module
* This module allows you to move a term from one vocabulary to another, or to
* reclassify a node
*/
/** 
* Implementation of hook_menu: Define menu links.
* 
* @note See hook_menu for a description of parameters and return values.
*/
function taxonomy_switch_menu() {
      $items['node/%node/classify'] = array(
        'title' => t('Classify'),
        'type' => MENU_LOCAL_TASK,
        'access callback' => "taxonomy_switch_check_local_tasks",
        'access arguments' => array(1),
        'page callback' => 'taxonomy_switch_node',
        'page arguments' => array(1),        
        );
  return $items;
}


function taxonomy_switch_perm() {

  return array(
    'taxonomy_switch_view'
  );    

}

function taxonomy_switch_check_local_tasks($node) {
// we introduce a new accses rule
  return (user_access('taxonomy_switch_view')); 
}

function taxonomy_switch_node() {
global $user;
  $op = $_POST['op']; 
  $edit = $_POST;
//  arg(1) is the nid
  if ($op) {
    $node = module_invoke('node', 'load', arg(1));
    taxonomy_node_save($node, $edit['taxonomy']);
    if (module_exists('checkout')) {
      module_invoke('checkout', 'checkin', arg(1));
      }
    watchdog('content', '%type: reclassified %title.', array('%type' => $node->type, '%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));
    drupal_set_message(t('The document has been reclassified'));
    print theme('page', $output);
    return;
    }
  if (module_exists('checkout')) {
    $checkout_info = module_invoke('checkout', 'checkout', arg(1));
    if ($checkout_info->uid == $user->uid) {
    $checked_out = FALSE;
    }
    else {
    $checked_out = TRUE;
    }
    }
  else {
    $checked_out = FALSE;
    }
  if (!$checked_out) {
  $output = drupal_get_form('taxonomy_switch_classify_form');
    return $output;
    }
   else {
     module_invoke('checkout', 'message', $checkout_info);
     }

}

/* In Drupal 5, forms must be created in dedicated builder functions */
function taxonomy_switch_classify_form($form_values = NULL) {
  
    $form = array();
    $form['taxonomy']['#tree'] = TRUE;
    $node = module_invoke('node', 'load', arg(1));
    drupal_set_title(check_plain($node->title));
      $node_vocabs = module_invoke('taxonomy', 'get_vocabularies', $node->type);
      foreach ($node_vocabs as $i => $vid) {
        $form['taxonomy'][$vid->vid] = module_invoke('taxonomy', 'form', $vid->vid);
        $node_terms = taxonomy_node_get_terms_by_vocabulary($node, $vid->vid);
        if ($vid->tags == 1) {
              $typed_string = array();
          foreach($node_terms as $ix => $n_tid) {
        $typed_string[] .= $n_tid->name;
        }
              $form['taxonomy']['tags'][$vid->vid]['#title'] = $form['taxonomy'][$vid->vid]['#title'];
              $form['taxonomy']['tags'][$vid->vid]['#description'] = $form['taxonomy'][$vid->vid]['#description'];
          $form['taxonomy']['tags'][$vid->vid]['#default_value'] = implode(', ', $typed_string);
          $form['taxonomy']['tags'][$vid->vid]['#type'] = 'textfield';
          $form['taxonomy']['tags'][$vid->vid]['#maxlength'] = 120;
          $form['taxonomy']['tags'][$vid->vid]['#size'] = 60;
          $form['taxonomy']['tags'][$vid->vid]['#autocomplete_path'] = 'taxonomy/autocomplete/'. $vid->vid;
              unset($form['taxonomy'][$vid->vid]);
          }
        else {
             $form['taxonomy'][$vid->vid]['#default_value'] = array_keys($node_terms);
             }
        if ($vid->required) {
             $form['taxonomy'][$vid->vid]['#required'] = TRUE;
          }
      }
    $form[] = array(
      '#type' => 'submit',
      '#value' => t("Classify"),
      );
//  $form['#redirect'] = FALSE;
  return $form;
}
asb’s picture

Hi kansaj,

I tried the code from #41; I created a directory ./sites/all/modules/taxonomy_switch and put the code into a file taxonomy_switch.module inside this directory.

After flushing the caches, the module doesen't show up at ./admin/build/modules. To be identified by D6 as a valid module, at least taxonomy_switch.info and taxonomy_switch.install files would be needed IMHO (I don't know if other files are missing, too).

Greetings, -asb

avpaderno’s picture

taxonomy_switch.info and taxonomy_switch.install files would be needed

Only taxonomy_switch.info, and taxonomy_switch.module are required for a module to be identified as a Drupal 6 module.

kansaj’s picture

StatusFileSize
new70.68 KB

Ok

So the code was not intended to be used as a standalone module. It was supposed to be tested and thereafter to be included in a module. Please download the uploaded file and use it. I think it works :)

asb’s picture

(Damn, d.o ate my reply with a "Guru Meditation" from varnish).

So once again in short: Thanks for the new packaged version; several files seem to belong to another module (from README.txt: "Allow to export views data to excel"). After manually renaming taxonomy_switch.info.txt to taxonomy_switch.info the module shows up at ./admin/build/modules.

However, after clearing the caches through 'admin_menu' on my nodes no "Classify" tab shows up. Sorry.

Thanks & greetings, -asb

kansaj’s picture

StatusFileSize
new6.03 KB

Hi
Sorry for the mess file. Please find the real file attached bellow. Pay attention to the newly introduced access.

cheers

kansaj’s picture

Hi, So i think we should check http://drupal.org/project/tagging . I think really nice concept :)

rkdesantos’s picture

The version in #46 seems to work nicely (alongside taxonomy manager).

asb’s picture

Status: Active » Reviewed & tested by the community

Hi,

confirming, that #46 works as advertised. Changing status to RTBC.

Greetings, -asb

naught101’s picture

Is there anything that this classify tab will do that the Tagging module in #47 can't already? if not, this issue should probably be closed.

asb’s picture

Yes; the patched module from #46 works as advertised, the 'Tagging' module does not yet, at least not out of the box. Getting a official release for the 'Taxomony Switch' fro D6 would at least bridge the time until 'Tagging' becomes production ready.

Greetings, -asb

nancydru’s picture

@Brigadier: One should only use "module_invoke" for hooks. For example, module_invoke('taxonomy', 'vocabulary_load', ...); is actually wrong (although it does work); it should be a simple API function call taxonomy_vocabulary_load(...);. If it had been coded properly, Coder would have flagged it for you right off the bat. Oh, and it executes faster too.

yngens’s picture

subscribe

avpaderno’s picture

One should only use "module_invoke" for hooks.

I see that some modules usemodule_invoke(), instead of directly calling the function to avoid to first verify if the function exists, and then call the function.
IMO, it's conceptually wrong to use module_invoke() for functions that are not actual implementations of hooks.

avpaderno’s picture

Title: Taxonomy Switch doesn't support Drupal v6.x » Add a Drupal 6.x release
Category: Support request » Task
Issue summary: View changes
Status: Reviewed & tested by the community » Closed (outdated)

I am closing this issue, since it's for a not supported Drupal version.