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

 
Nguyễn Siêu Hạnh nhận giải thưởng của Liên Hiệp Quốc

Nguyễn Siêu Hạnh nhận giải thưởng của Liên Hiệp Quốc

Chàng trai 25 tuổi Nguyễn Siêu Hạnh, sinh viên năm cuối khoa Quản trị kinh doanh, Học viện UBI (Bỉ), vừa nhận giải thưởng World Summit Youth Award của Liên Hiệp Quốc vào tháng 11 vừa qua tại Áo.

Add A Dropdown Admin Menu to Your Drupal Site

Thêm Dropdown Menu trong admin cho Drupal Site

One of things we often do for our training clients is simplify the admin area for them. There is a module that allows users to manage their site via a clean, dropdown menu. It has proven so popular that companies such as Acquia provide it by default to all their customers:

HTC One vẫn chỉ dừng lại ở rò rỉ thông tin giá bán

HTC One vẫn chỉ dừng lại ở rò rỉ thông tin giá bán

Thông tin về "siêu phẩm" điện thoại sắp ra mắt của HTC tiếp tục xuất hiện, lần này là hình ảnh về phiên bản màu đen và giá bán thông qua 4 nhà mạng lớn nhất thị trường Mỹ.

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

 

Diet con trung