Hướng dẫn xóa Content Types và Fields trong Drupal

Hướng dẫn xóa Content Types và Fields trong Drupal

Hướng dẫn sử dụng Redux để quản lý hiệu quả trong ứng dụng React

Average: 7.7 (3 votes)

Cài đặt Webpack để viết Reactjs bằng ES6 và những thuận lợi của ES6

Average: 9.5 (2 votes)

Hướng dẫn xóa Content Types và Fields trong Drupal

Here are two of the most common questions we get from Drupal newcomers:Hướng dẫn xóa Content Types và Fields trong Drupal

  • "What happens if I delete a content type?" 
  • "What happens if I delete a field?"

Because the answers are not easy to find, these kinds of questions can be confusing.

Here's a clear explanation of what happens when you delete a content type or field.

Deleting a Content Type

Hướng dẫn xóa Content Types và Fields trong Drupal

There are three questions to consider when deleting a content type:

  1. What happens to the content?
  2. What happens to the fields associated with the content type just deleted?
  3. What happens to the modules that interact with deleted content type?

1. What happens to the content?

Hướng dẫn xóa Content Types và Fields trong Drupal

The short answer to this question is, the nodes remain in the database. You can see the nodes listed in the Find Content admin page.

However, just because you can see them listed, does not mean you can open them. In fact, you can't; you get an error if you try.

2. What happens to the fields in the deleted content type?

Hướng dẫn xóa Content Types và Fields trong Drupal

The test content type that was just deleted had a test field (a field unique to the test content type) and the image field that comes with the Article content type. As you can see from the screen shot above, the image field is still there but the test field is not.

3. What happens to the modules that interact with the deleted content type?

There are contributed modules that add features to content types such as AddToAny and Webform to name two. In order to add the features provided by the module to the content type, quite often you check a box on the module's configuration page. The module then stores that decision as a configuration setting in the database.

What happens if you delete a content type without telling the module that is no longer needs to do something to that content type? In order to answer this question, I'd have to test quite a few modules to see if the developers of those modules took steps in their code to accommodate a content type suddenly going away. I offer you this however, if you have a content type you want to delete and you have modules on your site that add features to content types, consider disconnecting the content type from these other modules before you delete it.

Deleting a Field

In order to delete a field, you must go the content type where the field resides and delete it, unless of course you are deleting a content type. We saw earlier what happens to fields when we delete a content type. The fields shared across multiple content types remained but the fields unique to the deleted content type were also deleted. This same logic applies when you simply want to delete a field.

If the field you delete is unique to a content type, then the field is gone from the database (that includes it's data). If you delete a shared field from, the field is removed from that content type along with the data unique to the contenty type.

If you find that you need to keep the data associated with the field but you need a different type of field for the data, you need to plan ahead.

  1. Create the new field.
  2. Devise a way to migrate the data from the old field to the new field.
  3. Delete the old field.

Summary

Before you delete anything in Drupal, ask yourself how the "thing" you are about to delete is related to other things on the site. Is the content type related to existing nodes? Does the content have features managed by other modules? Has the field been used? If yes, will you need to save the data stored with the field?

Think things through before you delete.

Via Ostraining.com

Bạn thấy bài viết này như thế nào?: 
No votes yet

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

 
Xây dựng Multistep Registration Form trong Drupal 7 dùng Ctools

This article provides a step-by-step tutorial for creating a custom, multistep registration form via the Ctools Form Wizard in Drupal 7

Samsung Conquer 4G Review
Samsung Conquer 4G Review

Though to be a budget 4G devices, the Samsung Conquer 4G is very elegant and stylish. I was surprised at how well put together this phone is. The manufacturers seemed to have put a lot of attention to detail when making this gadget.

Yslow – Tối ưu hóa tốc độ website
Tối ưu hóa tốc độ website của bạn bằng Yslow

YSlow. Nó dựa trên các tiêu chí đánh giá chất lượng web speed và tối ưu hóa code của Yahoo! Hoặc cụ thể là một công cụ được implement theo chuẩn của các dev Yahoo cho việc tối ưu hóa website nhìn từ  client site.  Sau đây là điểm qua một số chức năng cơ bản của YSlow