在drupal7中动态的为某个内容类型添加字段
2013-08-16 13:07
387 查看
$myField_name = "my_new_field_name"; if(!field_info_field($myField_name)) // check if the field already exists. { $field = array( 'field_name' => $myField_name, 'type' => 'image', ); field_create_field($field); $field_instance = array( 'field_name' => $myField_name, 'entity_type' => 'node', 'bundle' => 'CONTENT_TYPE_NAME', 'label' => t('Select an image'), 'description' => t(''), 'widget' => array( 'type' => 'image_image', 'weight' => 10, ), 'formatter' => array( 'label' => t('label'), 'format' => 'image' ), 'settings' => array( 'file_directory' => 'photos', // save inside "public://photos" 'max_filesize' => '4M', 'preview_image_style' => 'thumbnail', 'title_field' => TRUE, 'alt_field' => FALSE, ) ); field_create_instance($field_instance); drupal_set_message("Field created successfully!"); }
相关文章推荐
- 在drupal7中动态的为某个内容类型添加字段
- drupal手动添加内容类型信息
- Drupal 添加内容时提示:你尚未创建过内容类型。
- Drupal新建内容类型后无法添加该类型的内容
- 自定义动态添加字段内容的库类
- GridView动态添加列并判断绑定数据DataTable的列类型控制展示内容
- SharePoint列表跟字段类型,网站栏,内容类型的关系
- 【转】【PB】动态添加数据窗口列中下拉列表的内容
- fieldset动态添加内容
- python爬取网页中javascript动态添加的内容(一)
- 使用.Net Reflection 反射机制 动态获取对象字段内容的示例
- Drupal 通过API动态的添加样式文件
- 用JavaScript往DIV动态添加内容
- MYSQL 在字段里现有内容后面添加字符串
- 浅谈js中如何动态添加表头/表列/表格内容
- 使用泛型, 写一个为任意类型的动态数组添加元素的方法
- drupal7 如何自定义内容部链接,并预留hook接口(自定义视图字段比较有用)
- drupal7 如何将一个date字段添加上日期插件效果
- jquery对动态添加内容添加事件
- 动态给表添加删除字段并同时修改它的插入更新存储过程