Recipe Views Bulk Operations Taxonomy assignment

Ingredients

Completed Recipe 17, or applied patch at http://drupal.org/node/1996 75

Completed Recipe 50

Taxonomy module (core module)

Actions module: http://drupal.org/project/actions

The Views Bulk Operations module (sometimes called VBO, for short) comes out of the box with powerful functionality as demonstrated in Recipe 50. Yet even more functionality is possible when combined with the Actions module. In this example, we enable bulk assignment of taxonomy terms for selected content items.

1. Install and enable the Actions and Taxonomy modules.

2. Create a vocabulary if you do not already have one available and populate it with terms at admin/content/taxonomy.

In the example below we have created a Level vocabulary and populated it with terms such as Easy, Medium, and Hard. The terms are weighted to appear alphabetically (Hard was given a weight of 1 while the others have a weight of 0).

Upon adding or editing the vocabulary, you may assign the vocabulary to a content type. In this case, the Level vocabulary is associated with Blog entries. Your vocabulary and content may vary for this exercise.

3. Configure actions at admin/settings/actions. Select Modify node's taxonomy terms.

Make a new advanced action available

MgdjflBg.de'sJax^

Choose an advanced action Change the author of a post... Unpublish post containing keyword(s),,, Display a message to the user,,, Send e-mail... Redirect to URL,,,

Unpublish comment containing kevword(s)...

Modify node s taxonomy terms...

Create

4. Assign the Description and Terms and check the Replace existing terms checkbox. In order to alphabetize Easy and Medium before Hard we would need to add an extra space after the arrow in the description.

Configure an advanced action

Description:

Taxonomy Term -> Easy (Replace)

A unique description for this advanced action. This description vnll be displayed in the interface of modules that integrate with actionsr such as Trigger module.

Terms:

lljffHW^BW^M *

Level: Medium Level: Hard topic: code topic: [ink topic: video

Choose the terms you want to associate with the nodes.

12] Replace existing terms

Check this box to replace existing terms with selected ones. Leave unchecked to add the newterms.

Repeat Step 4 for each term you wish to bulk-assign. Use the Description Taxonomy Term -> Hard (Replace) without the extra space after the arrow. This is a simple sorting method, but it works. Especially since the double spaces will not display in the final form.

5. Go to admin/build/views, and scroll down to the default views. Add a new view from the admin_content default view.

Default Views

Default view Title Description Provides URL

View, edit and admin_content Content delete your Page site's content.

Actions admin/content/node2 Overridden M

Make the following changes to the view. Views Quirks

I An especially important button in this recipe will be the Save and Edit button at the bottom of the page. This button resolves a Views quirk that sometimes hides the delete filter icons even after their exposed filters have been deleted. This behavior tends to occur when cloning a view or adding a default view.

Name admin_taxonomy

Access admin

Description Replace taxonomy terms

Provide Page Checked

View (Provide Page View is already checked.)

URL admin/content/taxonomy-change

View Type Bulk Operations View (This is already selected)

Title Modify Taxonomy Terms

Fields Explore, and leave as the default settings.

Filters Note that we are not able to delete the Front Page and Sticky fields here.

Node: Front Pa g s | Equals I | Yes |

¥

t

*

4

Filter by whether or not the node has been promoted to FrontPage.

Mode: Sticky | Equals 0 i Yes 0

*

#

1

Filter by whether or not the node is set sticky.

This behavior is expected because we cannot remove a filter that has already been exposed. For now just select one or more node types.

Filters

Field Operator Value Option Ops

Blag entry

Chat room

Node:Type

1 Is One Of 0

Page Story Video

, *

Include or exclude nodes of the selected types

Include or exclude nodes of the selected types

Exposed Filters

Filters

Save and Edit button

Filters

We will return to the Filters field set after taking actions in the Exposed Filters.

Click on the Delete icons for both the Node: Front Page and Node: Sticky fields.

Now go back and re-open the Filters field set. You may be puzzled that the Delete icons may still not be available. Typically the solution, when this happens, is to press Save and Edit at the bottom of the page. Leave the filters settings intact until the Delete icons appear.

The View Edit screen remains.

Return one last time to the Filters field set. Now the Delete icons should be available. Go ahead and delete the Node: Front Page and Node: Sticky fields from the filters list.

Node: Front Page | Equals |»f |Yes|*|

[ Expose j

® ¥

*

* £

Filter by whether or not the node has been promoted to Front Page.

Node: Sticky I Equals |.®.l Yes Ul

f Expose 1

m ¥

* M

Filter by whether or not the node is set sticky.

Additionally in the filters:

Add Taxonomy: Terms for Level, change the operator to Is One Of and click the Expose button (as usual, upon pressing the Expose button, the button disappears). If you find that you are missing a term be sure to apply the patch described in Recipe 17.

Exposed Finally, return to the Exposed Filters and assign a label for your

Filters vocabulary. In the example below we enter Level for the Level vocabulary. Enable the Optional checkbox.

Exposed Filters

Filter

Exposed Filters

Filter

Field

Label

Optional

settings Default

Force Single

Lock Operator

Ops

Node: Type

|Type

1 0

H

±

Node: Published

Published

1 H

IS T

*

k

Taxonomy: Terms for

|l_evel

1 H

m ?

Level

Save and Edit The View Edit screen remains

Click on the Settings tab (in the same line as View and Edit), and select the vocabulary terms operations.

EZ] Taxonomy Term -> Easy [Replace] (1) EZI Taxonomy Term -> Medium [Replace] (3) Taxonomy Term -> Hard [Replace] (5)

Test out the new view at admin_taxonomy. Try selecting, for instance, all entries that are not tagged with the Medium label, and other operations, as desired.

Type

Is One Of" T

Chat room Page Story Video

Published

Level

Is None Of \r I

<AH> -

Easy

Medium

Hard

Bulk operations

- Choose an operation -

Taxonomy Term -> Easy [Replace} i Taxonomy Term -> Medium (Replace) Taxonomy Term -> Hard (Replace)

Execute

Type

Author

Status

Edit

- Choose an operation -

Taxonomy Term -> Easy [Replace} i Taxonomy Term -> Medium (Replace) Taxonomy Term -> Hard (Replace)

Type

Author

Status

Edit

taxonomy_term

Blog entry

drupaltips

Published, Promoted

Edit

Drupal issue bookmark

Blog entry

drupaltips

Published, Promoted

Edit

Function Reference for your site

Blog entry

drupaltips

Published, Promoted

Edit

cvs sort

Blog entry

drupaltips

Published

Edit

+2 0

Responses

  • tuukka
    How to add taxonomy to node in bulk?
    7 years ago
  • John
    How to change n/a button in taxonomy in drupal?
    7 years ago
  • Samwise Goodchild
    How to make a view containing all taxonomy terms?
    7 years ago

Post a comment