Side Channel

  • home
  • resources
Home › Blogs › kamal's blog

User login

What is OpenID?
  • Log in using OpenID
  • Cancel OpenID login
  • Create new account
  • Request new password

Navigation

  • Books
  • Feed aggregator

Recent blog posts

  • Ubuntu mirrors up and improved!
  • Google-jstemplate: Iterate object with unknown properties
  • nginx https proxypass for php apps
  • sugarcrm & memcache: Doing it Wrong
  • subversion and https in Ubuntu Karmic
  • Drupal: Views block delta converted to md5 hash
  • Ubuntu Server install requires PAE
  • Installing Drupal from command line
  • Drupal: Handling form field weight through CCK
  • minify javascript using Google Closure Compiler
more

angch's location

angch twitter

  • angch: Heading to Brunei. Business class for a change.
more

Drupal: Namespace your CCK fields

kamal's picture

kamal — Wed, 03/06/2009 - 15:34

Not aware of this until it was too late. All CCK field was stored in a flat container in table node_field. It's not unique per content type. That means you cannot have two fields with a same name although that field was used in different content type. From the UI, if you create field with a same name, it'll just append an arbitrary number such as _0, _1 to make it unique. Until you look at the db table or need to use that field within your code, you'll not aware of that.

Solutions:-

  • If that particular field serve similar purpose, such as address which stay the same across content type, you can use shared field instead of creating new one.
  • If above not applicable, put a namespace (prefix) such as content type name to clearly identified to which content type that field belong. So instead of creating field kategori for both content type story and page which would result in field_kategori_0, field_kategori_1, named the field as story_kategori and page_kategori.

Consequence that we have right now which is too late to be fixed:-

db_name > SELECT field_name, type FROM node_field;
 field_borang                    | file
 field_objektif_0                | text
 field_fungsi_dan_aktiviti_0     | text
 field_piagam_pelanggan_0        | text
 field_misi_0                    | text
 field_dokumen_artikel           | file
 field_visi_0                    | text
 field_alamat_jabatan            | text
 field_nama_fail                 | file
 field_dokumen_0                 | file
 field_negeri                    | text
 field_negara                    | text
 field_no_syarikat               | text
 field_tarikh_daftar             | date
 field_deskripsi_2               | text

Related: Understanding CCK data storage

  • cck
  • drupal
  • kamal's blog
  • Add new comment


Creative Commons License

  • home
  • resources

Standard Disclaimer.