Add bulk operations for taxonomy terms

EvanDonovan - May 22, 2009 - 15:58
Project:Views Bulk Operations (VBO)
Version:6.x-1.7
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

This module is one of the most useful administrative tools available for Drupal 6. It would be great if it had operations available for taxonomy terms also. The ones I'm thinking of right now are:
* Delete term
* Switch vocabulary
* Set as a synonym

#1

kratib - May 22, 2009 - 17:25
Status:active» postponed

Thanks for your suggestions. I'm not sure when I'll have time to work on these, because I usually focus on the core VBO functionality and only add new actions when I need them myself. In the mean time, you're welcome to contribute code, and I'd be happy to assist you.

#2

EvanDonovan - May 22, 2009 - 23:12

Sounds reasonable. I can use the Actions API to add new bulk operations, correct?

#3

kratib - May 22, 2009 - 23:41

Correct. Take a look at http://drupal.org/node/459070 for an (incomplete) intro on writing actions for VBO.

Another thing, not yet mentioned in that guide, is that VBO has a general mechanism to support classes that Views 2 supports (Nodes, Users, Comments, Terms, etc). VBO achieves this generality by relying on hook_views_bulk_operations_object_info() to supply it with relevant info about those classes. However, VBO itself only implements this hook for classes Nodes, Users and Comments. You will have to implement this hook for Terms, like so:

function hook_views_bulk_operations_object_info() {
  return array(
    'term' => array(
      'type' => 'term',
      'base_table' => 'term_data',
      'load' => 'some function to load a term object given tid',
      'title' => 'name of the attribute that contains the term name',
    ),
  );
}

Then, your actions should be declared with attribute type = 'term' because that's how you declared the type in the hook.

Hope that's not too confusing :-)

#4

giorgio79 - June 19, 2009 - 05:48

Evan have you made any progress on this?

I just wanted to create a term based view with Bulk Operations, because with the term node count
http://drupal.org/project/term_node_count module
it would be one of the best ways to manage a taxonomy. Maybe even better than taxonomy manager. It would be easy to find orphaned terms etc etc. by sorting on the term node count :)

I notice there is already a taxonomy.action.inc but that is for nodes, so adding, deleting etc terms related to nodes.

Should I be expanding that file if I try to do some coding?

#5

kratib - June 19, 2009 - 06:26

@giorgio79: you can expand on taxonomy.action.inc if you wish. In any case you should attach your file here, to let me review it before committing it. If you start working on this, please set this issue to active and assigned to you. Thanks!

#6

giorgio79 - June 20, 2009 - 08:25

Thanks Karim.

I was looking at taxonomy.action.inc, which already has a
views_bulk_operations_taxonomy_action_info
but for operations on terms related to a node.

Do you have a preference for naming the term view related term operations sg like

views_bulk_operations_tern_action_info ?

Also, I noticed you have a delete.action.inc and a taxonomy.action.inc. Which one should contain the delete term action?
Could I get away with a delete term action in a term view just like this? (although I suspect this would not work because of the 'behavior' => array('deletes_node_property'), )

Add to delete_action.inc

// add this to function views_bulk_operations_delete_action_info() {
    'views_bulk_operations_delete_term_action' => array(
      'type' => 'term',
      'description' => t('Delete term'),
      'configurable' => FALSE,
      'behavior' => array('deletes_node_property'),
    ),
// end of  function views_bulk_operations_delete_action_info()  section


function views_bulk_operations_delete_term_action($tid) {
taxonomy_del_term($tid);
}

#7

EvanDonovan - June 20, 2009 - 17:59

giorgio79:
I haven't worked on this at all since my original post. Other priorities have come up at work. If I get around to it at all, it won't be for probably a month at least. But I'd love to review anything you come up with :)

#8

GreyHawk - July 16, 2009 - 18:45

I'd find this useful too -- I have a bunch of taxonomy terms and vocabularies that got loaded with incorrect node import and file settings, and need to eliminate a lot of them.

Can't seem to do it with Taxonomy Manager, and can't seem to do it with VBO (yet) -- in VBO, the lack of operations for taxonomy terms (and the complete lack of an "Operations" tab) are slowing me down.

:/

#9

kratib - July 16, 2009 - 20:24
Status:postponed» fixed

@GreyHawk: are you talking about Drupal 5? The "Operations" tab was renamed to "Settings" in D5, and it has been replaced by the "Bulk Operations" settings in D6.

I added support for terms, including an action to delete terms, in the latest dev.

#10

EvanDonovan - July 16, 2009 - 21:13

Excellent, thanks kratib!

#11

GreyHawk - July 16, 2009 - 21:39

Ah -- Drupal 6, not 5 -- thanks for the correction, kratib.

I need to download the latest Dev version to test then; I'm using the non-dev version.

#12

giorgio79 - July 16, 2009 - 23:37

Wow Karim, that is massive :)

With a term VBO this module could easily beat taxonomy manager.

A few default views for terms, nodes and users would make it even easier for users to get started.

What do you think? Perhaps I could post here mine for inclusion?

I built a
manage-node
manage-term
manage-user

VBO pages for administrative tasks :)

#13

giorgio79 - July 17, 2009 - 09:32

Just a tip, for your VBO term view.

If you install http://drupal.org/project/term_node_count you can see how many nodes belong to a term in your view.

#14

kratib - July 17, 2009 - 15:45

@giorgio, there's currently only one taxonomy action that I know of, namely the one to delete terms. As you said in your original report here, we need other actions such as move terms across taxonomies, make synonym, etc. Once we have those actions, we can create a HOWTO on the VBO guide to create a term administration interface.

#15

GreyHawk - July 19, 2009 - 22:19

@kratib -- still not able to see or load operations for terms/vocabularies, but can see other operations. I probably need to spend more time with it.;

Re: your later note re: actions for taxonomies, I'd find it useful to delete vocabularies... (not sure about anyone else)

#16

giorgio79 - July 27, 2009 - 16:52
Status:fixed» reviewed & tested by the community

Hey Karim,

It seems term delete vbo gone missing in the latest dev release :)

It was working fine with the previous one.

#17

kratib - July 28, 2009 - 00:54

@giorgio79: how is the "Delete term" action missing:

* Can you find it when you run an existing Term view?
* Can you find it when you edit an existing Term view?
* In delete.action.inc, are there a couple of places where you find views_bulk_operations_delete_term_action mentioned?
* In views_bulk_operations.module, function views_bulk_operations_views_bulk_operations_object_info(), can you find an entry for 'term'?

Also, please make sure you're not inadvertently using 2 copies of VBO in the same installation.

#18

giorgio79 - July 28, 2009 - 01:22
Status:reviewed & tested by the community» fixed

My apologies Karim, I was playing around with the Plugin Manager, and it overwritten my dev version with the previous stable one.

#19

System Message - August 11, 2009 - 01:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.