Vasyl Yaremchuk

How to transfer the content type settings by Features?

In the post How to Create Content Type in Drupal 7 Programmatically I told about creating content type with using .install file. But more often during development, we are dealing with a situation where some type of content is created in the admin to set up a specific field. These settings are made on staging while production site lived his own life, filled with new content and users. Obviously, it would be inexcusable mistake to overwrite production DB by staging ones. On the other hand, we can transfer all the settings manually, but it takes a long time, moreover, there is no guarantee that we do not forget anything. A simple solution to this issue is to use Features module. Lets we have the type of content portfolio (admin/structure/types/manage/portfolio/fields):

We should be sure that module Features exitsts and enabled. Lets go Administration » Structure » Features and click "Create Feature" tab. 

We should input "Name" and "Description" of our new feature. Also you can see "Version" and "URL of update XML", do not pay attention on them. Just now we are not going to provide our feature to somebody and make some new versions. Lets go ahead! Take a look on the second fieldset. We should select content type that we would like to export. On the right we can see dependencies. After we press download the feature will be ready for downloading. In the current case got portfolio_content_type.tar If you will take a look on content of this archive you can find module. Pay attention to the .info file. Module has dependencies: dependencies[] = "colorbox" dependencies[] = "features" dependencies[] = "image" dependencies[] = "strongarm" So on the site, where you would like to copy content type, these modules should be enabled. Copy this module to the other site and you can see it in the list of modules: 

But you should not turn on it here. Please, go to Administration » Structure » Features: 

You can see the list of all features available. On this cas there is only one Feature. You can turn on it to click on "Disabled". And new content type with corresponding field settings will appear! Good! It is more simple way to create content on the site by one click that I told in the topic How to Create Content Type in Drupal 7 Programmatically. But it is feature based method, in the post that I mention content type was created without Features module, it is more native way, more preferable for the Code Driven Development approach.