2

I need to manually update the display settings for my content types. I have a lot of content types and I don't want to have to do it one-by-one using the UI. Where can I show/hide fields for Default and teaser displays for content types directly in the DB?

0
+50

Backup your database then ...

The tables that you want to deal with are:

field_config

  • The main field configuration

field_config_instance

  • The field configuration on a particular entity bundle.

You can use database administration navigate to the table 'field_config' to see that there is a column titled 'deleted' and a value of '0' for active and '1' for deleted fields (they should stay in your database because you've not burrowed down to the field specific tables)

Using Mysql run:

UPDATE field_config SET deleted = 1 where field_name = 'field_my_unwanted_field_1','field_my_unwanted_field_2';
TRUNCATE TABLE cache_field;

In the event that you also need to fiddle the 'field_config_instance' table

UPDATE field_config_instance SET deleted = 1 where field_name = 'field_my_unwanted_field_1','field_my_unwanted_field_2';
TRUNCATE TABLE cache_field;
5
  • I am unsure if my mark-up for editing multiple table values is accurate i.e: apostrophe-fieldname_1-apostrophe-comma-apostrophe-fieldname_2-apostrophe-semicolon If someone could confirm that'd be helpful to me. Jun 18 '14 at 20:33
  • 2
    I don't think the active column in that table controls visibility for the field. I believe visibility is defined in the serialized array in the data column. Jun 18 '14 at 21:11
  • @AdamBalsam In which case the 'Deleted' Column should work - I've changed my answer to reflect this... Jun 18 '14 at 21:18
  • 1
    No, I think the deleted column has to do with batch deleting data after a field that had data stored in it has been deleted through the UI. Jun 19 '14 at 19:55
  • I know from accidentally deleting a field that you are right. However the deleted column also functions to show/hide the field from the site. (It's the last thing you need to restore when 'undoing' the accidental delete process...) And it's useful because you just flip the switch on the database to get it back. I.e. it's not really 'deleted' rather its just labeled as such. Jun 19 '14 at 22:49
2

With basic Drupal, the db table is field_config_instance, all in the "data" column.

With Display suite, you should also look at ds_fields, ds_field_settings, ds_layout_settings.

(Use drush sqlc for a mysql commandline, and then "describe ds_field_settings;" etc.)

This being said, you really want to look for API functions. Look at:

1
  • Duh, I think I did not read the other reply by gl2748 carefully enough. Or not at all maybe?
    – donquixote
    Jun 18 '14 at 20:29
0

A different approach would be to use Features module and export your content types as features, edit the exported file with find/replace or whatever, then import the feature.

Another possibility would be to use https://drupal.org/project/configuration

6
  • While these are great options, these are not what I need. This is a one-off website that I need to change about 30 content types (both default and teaser settings). Doing it via features and config is not an option and would actually take more time to do then even doing it in the UI manually one-by-one. May 27 '14 at 19:25
  • Ok, I just thought I would offer that. May 27 '14 at 19:27
  • I didn't downvote it. Someone else did. May 27 '14 at 19:29
  • Ok, edited my comment. May 27 '14 at 19:30
  • From my perspective, Features is the most simple and accurate approach for the task. “directly in the DB” isn't good idea for Drupal and for any other framework with rich API, I guess.
    – kalabro
    Jun 19 '14 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.