【发布时间】:2015-05-19 16:45:32
【问题描述】:
我正在开发一个自定义模块,它允许我创建一个自定义文本字段,我需要在其中插入一个 HTTP 请求的 URL。
我现在唯一想做的就是从文本字段中获取值并显示在节点的某个位置。
这是 .install 代码:
function graph_field_enable() {
$field = array(
'field_name' => 'graph_field',
'type' => 'text',
);
field_create_field($field);
/**
* Bind field to a entity bundle.
*/
$instance = array(
'field_name' => $field['field_name'],
'entity_type' => 'node',
'bundle' => 'station',
);
field_create_instance($instance);
}
/**
* Implements hook_disable().
*
* Remove field from node bundle (content type) and then delete the field.
*/
function graph_field_disable() {
$instance = array(
'field_name' => 'graph_field',
'entity_type' => 'node',
'bundle' => 'station',
);
field_delete_instance($instance);
field_delete_field($instance['field_name']);
print 'Removed ' . $instance['field_name'] . "\n";
}
.module 文件只包含:
<?php
我对 Drupal 很陌生,我想我讨厌它。
【问题讨论】:
标签: php drupal drupal-7 drupal-modules