function views_pivot_test_install in Pivot Tables for Views 7
Implements hook_install().
File
- tests/
views_pivot_test/ views_pivot_test.install, line 11 - views_pivot_test.install Contains install hooks.
Code
function views_pivot_test_install() {
// Favourite colour field on pivot nodes.
$field = array(
'field_name' => 'field_test_pivot_colour',
'cardinality' => 1,
'type' => 'list_text',
'settings' => array(
'allowed_values' => array(
'red' => 'Red',
'blue' => 'Blue',
'green' => 'Green',
),
),
);
field_create_field($field);
$instance = array(
'field_name' => 'field_test_pivot_colour',
'entity_type' => 'node',
'bundle' => 'pivot',
'label' => 'Colour',
'widget' => array(
'type' => 'options_buttons',
),
'display' => array(
'default' => array(
'label' => 'hidden',
'type' => 'list_default',
),
),
);
field_create_instance($instance);
$node = (object) array(
'type' => 'pivot',
'uid' => 1,
'title' => 'Red - January',
'created' => strtotime('2013-01-01 00:00'),
);
$node->field_test_pivot_colour[LANGUAGE_NONE][0]['value'] = 'red';
node_save($node);
$node = (object) array(
'type' => 'pivot',
'uid' => 1,
'title' => 'Red - February',
'created' => strtotime('2013-02-01 00:00'),
);
$node->field_test_pivot_colour[LANGUAGE_NONE][0]['value'] = 'red';
node_save($node);
$node = (object) array(
'type' => 'pivot',
'uid' => 1,
'title' => 'Blue - February',
'created' => strtotime('2013-02-01 00:00'),
);
$node->field_test_pivot_colour[LANGUAGE_NONE][0]['value'] = 'blue';
node_save($node);
}