Solution for unavailable CCK fields in Drupal 6 Views

Problem: Using Drupal 6 Views UI, you want to add a particular CCK field (say, as a filter), but this field seems to be not offered at all for some reason. Because most Drupal code is not protected by assertions (amateur coding?), corrupt data is likely to flow far before a visible problem is eventually triggered.

Solution: My particular trouble was caused by a Drupal 5 to Drupal 6 CCK migration bug concerning number_integer fields. However, given the general nature of this problem I decided to record some general troubleshooting tips here.

One thing to check for is metadata corruption - the Views module might be working properly, but the CCK module might not be delivering a correct description of the affected field for some reason.

As a first guess, examine the field's entry in the content_node_field table (and perhaps also content_node_field_instance), particularly look at the db_columns attribute. Does it appear unusual when compared to other, correctly working fields?

If you are out of luck so far, here are two locations in code where to install debug output to gather more information:

  • Right after the call to views_fetch_fields in function views_ui_add_item_form - does your field appear in the $options array, as it should? (probably not)
  • content_views_field_views_data - how does the returned structure for your field compare to those of other (working) fields?

To trigger calls to these function interact with the Views UI (e.g. click the add filter button), but do not forget to /devel/cache/clear each time! Otherwise the critical code paths will not be traversed due to caching.

No comments:

Post a Comment