37
CCK to Fields Getting There From Here Karen Stevenson, CCK maintainer Tuesday, April 20, 2010

CCK to Fields - · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Embed Size (px)

Citation preview

Page 1: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

CCK to FieldsGetting There From Here

Karen Stevenson, CCK maintainer

Tuesday, April 20, 2010

Page 2: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

How We Got Here

• Flexinode

• CCK

• Fields in core

Tuesday, April 20, 2010

Page 3: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Flexinode

• Jonathan Chaffer (JonBob)

• Useful life: 2004 - 2007

• Drupal versions: 4.4 - 4.7

• http://drupal.org/project/flexinode

Tuesday, April 20, 2010

Page 4: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Flexinode Architectureflexinode_field flexinode_type

flexinode_data

Tuesday, April 20, 2010

Page 5: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

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

Page 6: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Flexinode

Tuesday, April 20, 2010

Page 7: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

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

Page 8: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

CCK

• Totally re-architected:

• Custom content types moved to core in D6

• Custom fields moved to core in D7

Tuesday, April 20, 2010

Page 9: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

CCK Field Architecturenode_type_content

node_field

node_field_instance

XTuesday, April 20, 2010

Page 11: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Later Data Architecture

per_content_type per_field_type

Tuesday, April 20, 2010

Page 12: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

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

Page 13: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Database Optimization

• Per Bundle Storagehttp://drupal.org/project/pbs

• Materialized Viewhttp://drupal.org/project/materialized_view

Tuesday, April 20, 2010

Page 14: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

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

Page 15: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

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

Page 16: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

New Fieldable Entities

• Users (were entities but not fieldable)

• Commentshttp://drupal.org/node/504666

• Taxonomyhttp://drupal.org/node/413192

Tuesday, April 20, 2010

Page 17: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

New Fieldable Entities NOT!

• Blocks, never completedhttp://drupal.org/node/430886

Tuesday, April 20, 2010

Page 18: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

New Core Fields• Body & teaser

http://drupal.org/node/372743

• Commentshttp://drupal.org/node/538164

• Taxonomyhttp://drupal.org/node/412518

Tuesday, April 20, 2010

Page 19: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

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

Page 20: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

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

Page 21: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

List: Allowed Values

• Allowed values from php: in CCK

• Another allowed values alternative:http://drupal.org/project/options_element

Tuesday, April 20, 2010

Page 22: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

List: Allowed Values

Tuesday, April 20, 2010

Page 23: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Translatable Fields

• $node->body[0][value]$node->body[$langcode][0][value]

• $langcode = FIELD_LANGUAGE_NONE;

• http://drupal.org/node/367595

Tuesday, April 20, 2010

Page 24: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

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

Page 25: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Nodereference

• Still in CCK, but functional

• Move to separate module?http://drupal.org/project/noderelationships

• http://drupal.org/node/533222

Tuesday, April 20, 2010

Page 26: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Userreference

• Still in CCK, but functional

• Move to new module? No immediate candidates

• http://drupal.org/node/533222

Tuesday, April 20, 2010

Page 27: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Fieldgroup

• Still in CCK and non-functional

• Move to new module? No immediate candidates

Tuesday, April 20, 2010

Page 28: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Content Permissions

• Still in CCK and non-functional

• Move to new module? http://drupal.org/project/field_permissions

Tuesday, April 20, 2010

Page 29: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Content Copy

• Still in CCK and non-functional

• Move to new module? http://drupal.org/project/content_type_exporter

Tuesday, April 20, 2010

Page 30: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Views

• Views is still contrib, so views integration is not in core

• http://drupal.org/views

Tuesday, April 20, 2010

Page 31: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Devel Generate

• Devel is still contrib, so Devel generate integration is not in core

• http://drupal.org/devel

Tuesday, April 20, 2010

Page 32: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Diff

• Diff is still contrib, so diff integration is not in core

• http://drupal.org/diff

Tuesday, April 20, 2010

Page 33: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Rules

• Rules is still contrib, so rules integration is not in core

• http://drupal.org/rules

Tuesday, April 20, 2010

Page 34: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Token

• Token module is now in core, but token integration is still in contrib

• http://drupal.org/project/token

Tuesday, April 20, 2010

Page 35: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

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

Page 36: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

CONSULTINGDEVELOPMENT

TRAINING

& donʼt forget videos!

Tuesday, April 20, 2010

Page 37: CCK to Fields -   · PDF fileCCK to Fields Getting There From Here ... •Drupal versions: 4.4 - 4.7 ... Field Data Architecture

Tuesday, April 20, 2010