Upload
hoangthuan
View
223
Download
2
Embed Size (px)
Citation preview
CCK to FieldsGetting There From Here
Karen Stevenson, CCK maintainer
Tuesday, April 20, 2010
How We Got Here
• Flexinode
• CCK
• Fields in core
Tuesday, April 20, 2010
Flexinode
• Jonathan Chaffer (JonBob)
• Useful life: 2004 - 2007
• Drupal versions: 4.4 - 4.7
• http://drupal.org/project/flexinode
Tuesday, April 20, 2010
Flexinode Architectureflexinode_field flexinode_type
flexinode_data
Tuesday, April 20, 2010
function flexinode_load($node) { $ctype = flexinode_load_content_type(substr($node->type, 10)); // build the query $fields_to_select = array(); $table_joins = array(); foreach ($ctype->fields as $field) { $fieldname = 'flexinode_'. $field->field_id; if ($field_to_select = flexinode_invoke('db_select', $field)) { $fields_to_select[] = $field_to_select; $table_joins[] = 'LEFT JOIN {flexinode_data} '. $fieldname .' ON n.nid = '. $fieldname .'.nid AND '. $fieldname .'.field_id = ' . $field->field_id; } } if (count($fields_to_select) > 0) { // make the query $flexinode = db_fetch_object(db_query('SELECT '. implode(', ', $fields_to_select) .' FROM {node} n '. implode(' ', $table_joins) .' WHERE n.nid = %d', $node->nid));
// unserialize necessary fields foreach ($ctype->fields as $field) { $fieldname = 'flexinode_'. $field->field_id; $field_data = flexinode_invoke('load', $field, $flexinode); if ($field_data) { $flexinode->$fieldname = $field_data; } } } $flexinode->ctype_id = $ctype->ctype_id; return $flexinode;}
Flexinode Node Load
Tuesday, April 20, 2010
Flexinode
Tuesday, April 20, 2010
Content Construction Kit (CCK)
• Total rewrite to scale better
• Useful life: 2007 - 2010
• Drupal versions: 4.7 - 6.x
• http://drupal.org/project/cck
Tuesday, April 20, 2010
CCK
• Totally re-architected:
• Custom content types moved to core in D6
• Custom fields moved to core in D7
Tuesday, April 20, 2010
CCK Field Architecturenode_type_content
node_field
node_field_instance
XTuesday, April 20, 2010
Early Data Architecture node_field_shorttext_data
node_field_int_data
node_field_longtext_datanode_field_float_data
Tuesday, April 20, 2010
Later Data Architecture
per_content_type per_field_type
Tuesday, April 20, 2010
Field Data Architecture
• Change settings or share a field after data was created -> potential data loss.
• Settled on using per-field storage for all fields, data never moves.
Tuesday, April 20, 2010
Database Optimization
• Per Bundle Storagehttp://drupal.org/project/pbs
• Materialized Viewhttp://drupal.org/project/materialized_view
Tuesday, April 20, 2010
Module Upgrades
• Use Coder and Coder Upgrade module, then start on field issueshttp://drupal.org/project/coder
• Upgrade documentation:http://drupal.org/node/728792
Tuesday, April 20, 2010
Data Upgrades
• May not be a normal upgrade, likely an upgrade page listing all fields and upgrade status
• Issue to track:http://drupal.org/node/366364
Tuesday, April 20, 2010
New Fieldable Entities
• Users (were entities but not fieldable)
• Commentshttp://drupal.org/node/504666
• Taxonomyhttp://drupal.org/node/413192
Tuesday, April 20, 2010
New Fieldable Entities NOT!
• Blocks, never completedhttp://drupal.org/node/430886
Tuesday, April 20, 2010
New Core Fields• Body & teaser
http://drupal.org/node/372743
• Commentshttp://drupal.org/node/538164
• Taxonomyhttp://drupal.org/node/412518
Tuesday, April 20, 2010
File/Image Fields
• Filefield and imagefield moved to core, upload module has been removed
• http://drupal.org/node/391330
• http://drupal.org/node/560780
Tuesday, April 20, 2010
New Field Type: List
• New ʻListʼ field type in core
• Boolean, numeric, or alpha keys
• Allowed values as textarea with ʻkey | valueʼ pairs
Tuesday, April 20, 2010
List: Allowed Values
• Allowed values from php: in CCK
• Another allowed values alternative:http://drupal.org/project/options_element
Tuesday, April 20, 2010
List: Allowed Values
Tuesday, April 20, 2010
Translatable Fields
• $node->body[0][value]$node->body[$langcode][0][value]
• $langcode = FIELD_LANGUAGE_NONE;
• http://drupal.org/node/367595
Tuesday, April 20, 2010
User Profile Fields
• D7 core: user fields & profile module
• Create new ʻprofileʼ entity in contrib?http://drupal.org/node/394720http://drupal.org/node/301071http://drupal.org/project/profile2
Tuesday, April 20, 2010
Nodereference
• Still in CCK, but functional
• Move to separate module?http://drupal.org/project/noderelationships
• http://drupal.org/node/533222
Tuesday, April 20, 2010
Userreference
• Still in CCK, but functional
• Move to new module? No immediate candidates
• http://drupal.org/node/533222
Tuesday, April 20, 2010
Fieldgroup
• Still in CCK and non-functional
• Move to new module? No immediate candidates
Tuesday, April 20, 2010
Content Permissions
• Still in CCK and non-functional
• Move to new module? http://drupal.org/project/field_permissions
Tuesday, April 20, 2010
Content Copy
• Still in CCK and non-functional
• Move to new module? http://drupal.org/project/content_type_exporter
Tuesday, April 20, 2010
Views
• Views is still contrib, so views integration is not in core
• http://drupal.org/views
Tuesday, April 20, 2010
Devel Generate
• Devel is still contrib, so Devel generate integration is not in core
• http://drupal.org/devel
Tuesday, April 20, 2010
Diff
• Diff is still contrib, so diff integration is not in core
• http://drupal.org/diff
Tuesday, April 20, 2010
Rules
• Rules is still contrib, so rules integration is not in core
• http://drupal.org/rules
Tuesday, April 20, 2010
Token
• Token module is now in core, but token integration is still in contrib
• http://drupal.org/project/token
Tuesday, April 20, 2010
Multigroup
• Might be able to create a field which is itself a fieldable entity to inherit this function
• http://drupal.org/node/695636
• http://drupal.org/node/494100
Tuesday, April 20, 2010
CONSULTINGDEVELOPMENT
TRAINING
& donʼt forget videos!
Tuesday, April 20, 2010
Tuesday, April 20, 2010