-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirst.install
More file actions
55 lines (54 loc) · 1.42 KB
/
first.install
File metadata and controls
55 lines (54 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* Implements hook_install().
*/
function first_install() {
variable_set('first_default_centre_lat', -75.569851);
$t = get_t();
drupal_set_message($t('first variables created'));
/**
* content type definition
*/
$content_type = array(
'type' => 'first',
'name' => $t('first'),
'description' => $t('a first module content type'),
'title_label' => $t('first name'),
'base' => 'node_content',
'custom' => TRUE,
);
$node_type = node_type_set_defaults($content_type);
//save the content type
node_type_save($node_type);
//add body field
node_add_body_field($node_type, $t('description'));
//add fields
$fields = array();
$fields['first_field'] = array(
'field name' => 'first field1',
'type' => 'number_integer',
'cardinality' => 1,
'settings' => array(
'max_length' => 5,
)
);
$fields['second_field'] = array(
'field name' => 'Second field1',
'type' => 'number_float',
'cardinality' => 1,
'settings' => array(
'max_length' => 5,
)
);
foreach ($fields as $field) {
field_create_field($field);
}
}
/**
* implements hook_uninstall
*/
function first_uninstall() {
variable_del('first_default_centre_lat');
$t = get_t();
drupal_set_message($t('first variables deletedd'));
}