DrupalCon DC

I made a presentation about CCK at DrupalCon called CCK Mashup, Oh The Things You Can Do.

I showed how you can use a custom content type with a nodereference field and Views to manage custom blocks that should show up on specific site pages. The video is up at http://www.archive.org/details/DrupalconDc2009-CckMashupOhTheThingsYouC….

The Content Copy export of the content type and field is:

$content[type] = array (
'name' => 'Block',
'type' => 'block',
'description' => 'Dynamic block content for site landing pages.',
'title_label' => 'Title',
'body_label' => 'Body',
'min_word_count' => '0',
'help' => '',
'node_options' =>
array (
'status' => true,
'promote' => false,
'sticky' => false,
'revision' => false,
),
'old_type' => 'block',
'orig_type' => '',
'module' => 'node',
'custom' => '1',
'modified' => '1',
'locked' => '0',
'comment' => '0',
'comment_default_mode' => '4',
'comment_default_order' => '1',
'comment_default_per_page' => '50',
'comment_controls' => '3',
'comment_anonymous' => 0,
'comment_subject_field' => '1',
'comment_preview' => '1',
'comment_form_location' => '0',
'ant' => '0',
'ant_pattern' => '',
'ant_php' => 0,
);
$content[fields] = array (
0 =>
array (
'label' => 'Show on page',
'field_name' => 'field_block_related',
'type' => 'nodereference',
'widget_type' => 'nodereference_select',
'change' => 'Change basic information',
'weight' => '-4',
'autocomplete_match' => 'contains',
'description' => '',
'default_value' =>
array (
0 =>
array (
'nid' => '',
),
),
'default_value_php' => '',
'default_value_widget' => NULL,
'group' => false,
'required' => 0,
'multiple' => '0',
'referenceable_types' =>
array (
'event' => 'event',
'story' => 'story',
'team' => 'team',
'block' => 0,
'book' => 0,
'fisherman' => 0,
'groups' => 0,
'page' => 0,
'picture' => 0,
'result' => 0,
'test' => 0,
'place' => false,
),
'advanced_view' => '--',
'advanced_view_args' => '',
'op' => 'Save field settings',
'module' => 'nodereference',
'widget_module' => 'nodereference',
'columns' =>
array (
'nid' =>
array (
'type' => 'int',
'unsigned' => true,
'not null' => false,
),
),
'display_settings' =>
array (
'label' =>
array (
'format' => 'above',
'exclude' => 0,
),
'teaser' =>
array (
'format' => 'default',
'exclude' => 0,
),
'full' =>
array (
'format' => 'default',
'exclude' => 0,
),
4 =>
array (
'format' => 'default',
'exclude' => 0,
),
2 =>
array (
'format' => 'default',
'exclude' => 0,
),
3 =>
array (
'format' => 'default',
'exclude' => 0,
),
'email_plain' =>
array (
'format' => 'default',
'exclude' => 0,
),
'email_html' =>
array (
'format' => 'default',
'exclude' => 0,
),
'token' =>
array (
'format' => 'default',
'exclude' => 0,
),
),
),
);
$content[extra] = array (
'title' => '-5',
'body_field' => '-3',
'menu' => '-1',
'book' => '-2',
);

The export of the view is:

$view = new view;
$view->name = 'custom_blocks';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
'field_block_related_nid' => array(
'label' => 'Show on page',
'link_to_node' => 1,
'label_type' => 'widget',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_block_related_nid',
'table' => 'node_data_field_block_related',
'field' => 'field_block_related_nid',
'relationship' => 'none',
),
'title' => array(
'label' => 'Title',
'link_to_node' => 0,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'body' => array(
'label' => 'Body',
'exclude' => 0,
'id' => 'body',
'table' => 'node_revisions',
'field' => 'body',
'relationship' => 'none',
),
'delete_node' => array(
'label' => 'Delete link',
'text' => '',
'exclude' => 0,
'id' => 'delete_node',
'table' => 'node',
'field' => 'delete_node',
'relationship' => 'none',
),
'edit_node' => array(
'label' => 'Edit link',
'text' => '',
'exclude' => 0,
'id' => 'edit_node',
'table' => 'node',
'field' => 'edit_node',
'relationship' => 'none',
),
'status' => array(
'label' => 'Published',
'type' => 'yes-no',
'not' => 0,
'exclude' => 0,
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'field_block_related_nid' => array(
'default_action' => 'default',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'default_argument_type' => 'node',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'break_phrase' => 0,
'not' => 0,
'id' => 'field_block_related_nid',
'table' => 'node_data_field_block_related',
'field' => 'field_block_related_nid',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_argument_is_member' => 0,
'validate_argument_signup_status' => 'any',
'validate_argument_signup_node_access' => 0,
'validate_argument_php' => '',
),
));
$handler->override_option('filters', array(
'type' => array(
'operator' => 'in',
'value' => array(
'block' => 'block',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('style_options', array(
'grouping' => '',
));
$handler->override_option('row_options', array(
'inline' => array(
'edit_node' => 'edit_node',
'delete_node' => 'delete_node',
),
'separator' => '|',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('arguments', array());
$handler->override_option('title', 'Custom Feature Blocks');
$handler->override_option('header', 'Create block content.');
$handler->override_option('header_format', '1');
$handler->override_option('header_empty', 1);
$handler->override_option('empty', 'No blocks have been created. ');
$handler->override_option('empty_format', '1');
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
'grouping' => '',
'override' => 1,
'sticky' => 0,
'order' => 'asc',
'columns' => array(
'field_block_related_nid' => 'field_block_related_nid',
'title' => 'title',
'body' => 'body',
'delete_node' => 'delete_node',
'edit_node' => 'edit_node',
'status' => 'status',
),
'info' => array(
'field_block_related_nid' => array(
'separator' => '',
),
'title' => array(
'sortable' => 0,
'separator' => '',
),
'body' => array(
'separator' => '',
),
'delete_node' => array(
'separator' => '',
),
'edit_node' => array(
'separator' => '',
),
'status' => array(
'sortable' => 0,
'separator' => '',
),
),
'default' => '-1',
));
$handler->override_option('path', 'blocks/edit');
$handler->override_option('menu', array(
'type' => 'normal',
'title' => 'Feature Blocks',
'weight' => '0',
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));
$handler = $view->new_display('block', 'Custom block', 'custom_block_1');
$handler->override_option('fields', array(
'title' => array(
'label' => '',
'link_to_node' => 0,
'exclude' => 1,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
'override' => array(
'button' => 'Use default',
),
),
'edit_node' => array(
'label' => '',
'text' => '',
'exclude' => 0,
'id' => 'edit_node',
'table' => 'node',
'field' => 'edit_node',
'relationship' => 'none',
'override' => array(
'button' => 'Use default',
),
),
'delete_node' => array(
'label' => '',
'text' => '',
'exclude' => 0,
'id' => 'delete_node',
'table' => 'node',
'field' => 'delete_node',
'override' => array(
'button' => 'Use default',
),
'relationship' => 'none',
),
'body' => array(
'label' => '',
'exclude' => 0,
'id' => 'body',
'table' => 'node_revisions',
'field' => 'body',
'relationship' => 'none',
'override' => array(
'button' => 'Use default',
),
),
));
$handler->override_option('filters', array(
'type' => array(
'operator' => 'in',
'value' => array(
'block' => 'block',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
'override' => array(
'button' => 'Use default',
),
),
'status' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'override' => array(
'button' => 'Use default',
),
'relationship' => 'none',
),
));
$handler->override_option('block_description', 'Custom feature');
$handler->override_option('block_caching', -1);