Hướng dẫn gắn taxonomy terms to nodes sử dụng Views Bulk Operations

Hướng dẫn gắn taxonomy terms to nodes sử dụng Views Bulk Operations

In this article I am going to show you a quick trick that will allow you to assign taxonomy terms to a lot of nodes all at once. For this we will use Views and Views Bulk Operations and will require no coding whatsoever. So let's begin.

First off, make sure you have the 2 modules installed. Drush will quickly take care of that for you if you don't have them yet:

drush dl ctools views vbo && drush en ctools views views_ui vbo

Now, the next thing we need to do is create a View page that displays the content (nodes, users, etc) you'd like to operate on in bulk (in our case, add taxonomy terms to). Make sure it uses fields and for start, the title field will be enough. For filtering, use whatever you need to filter the View to show only the content you want and sorting doesn't really matter.

Next up, add a new field of the type:Bulk operations: Content . This will provide next to the node title a checkbox for you to select that node to be part of the bulk operation.

To configure this field, make sure you check the boxes Modify entity values and Show available tokens followed by selecting the values of which field you'd like changed (in our case the taxonomy term reference field). In the screenshot below, you can see my selection for the Tags field of the Article node (I am going with a node view displaying articles).

Now you can save the View and navigate to its page. In the image below you can see my example. A table formatted view with the checkbox and the Article node title to its right. And the VBO operations above it.

How to batch assign taxonomy terms to nodes using Views Bulk Operations

Now, let's say I want to apply a taxonomy term to all these nodes. I can select them all (either manually or using the top-most checkbox dedicated for selecting all rows at once), choose my operation (Modify entity values) and click Execute. And this is then my next screen:

I have an autocomplete widget (like the default Article content type Tags field referencing taxonomy terms) where I can select one or more terms I'd like applied to all those nodes. I also have an option to ensure that existing values do not get overriden, by checking the respective checkbox. And lastly, I have some tokens available to use (because of the Tokens module).

Once I select my terms and press Next, I get an overview of how many nodes are going to be affected by this change (as you can see below). And that's basically it.

One thing to keep in mind here. If you are adding a non already existing taxonomy term, VBO will create that term as many times as the number of nodes being processed. So you'll end up with a bunch of terms with the same title. Probably not something you either expect or want. I therefore recommend you create your term before and then apply it to the content.

Hope this helps!

Bạn thấy bài viết này như thế nào?: 
Average: 5 (1 vote)
Ảnh của Khanh Hoang

Khanh Hoang - Kenn

Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Microsoft thắt chặt cấp phép bản quyền Windows 8?

Microsoft thắt chặt cấp phép bản quyền Windows 8?

Một loạt các slide trình diễn bị rò rỉ trên mạng đã tiết lộ thông tin về OEM Activation mới trên Windows 8 được thiết kế để gây khó khăn cho việc kích hoạt bản quyền bất hợp pháp trong hệ điều hành mới của Microsoft.

8 Tip nhỏ cần nhớ cho Testing Drupal

8 Tip nhỏ cần nhớ cho Testing Drupal

Many Drupal projects now under maintenance suffer from technical debt: a lot of the functionality is in the database and outside of git, and the code lacks automated testing

Seo top

Bài 6: OFFPAGE SEO và kiếm tiền với Google Adsense

Bước OFFPAGE SEO có lẽ là bước gian nan nhất trong quá trình kiếm tiền với Google Adsense. Đây là bước mà mỗi người phải tự tìm cho mình một lối đi riêng.

Công ty diệt chuột T&C

 

Diet con trung