我有两种内容类型,都有节点标题和文档附件,文档附件字段是不同的名称(来自两种不同的内容类型).
在我看来,我在表格中显示节点标题和文件名.节点标题在一列中都很棒,但是两个内容类型的附件字段显示在两个单独的列中,当应该只有两个列时,总共有三列.每行都有一个文档标题,但现在一个或另一个列总是空白,具体取决于显示的内容类型的文档标题.
如何将这两个字段组合在一起显示在同一列中,使其看起来无缝?知道这些文档来自两种不同的内容类型并不重要.这些是通过更大的分类术语组织的,因此仅仅做两种不同的观点是不可行的.
我正在尝试为文本字段创建一个新的自定义字段格式化程序,但根本没有显示任何内容.
我尝试卸载并重新安装模块并多次刷新缓存,但没有任何效果.
这是我使用的代码
/**
* Implementation of hook_field_formatter_info()
*/
function facebooklink_field_formatter_info()
{
return array(
'cfieldformatter_text_1' => array(
'label' => t('Text 1'),
'field types' => array('text', 'text_long', 'text_with_summary'),
'settings' => array(
'pic_size' => 'small',
'tooltip' => 'Link to user Facebook page',
),
),
);
}
/**
* Implementation of hook_field_formatter_settings_form()
*/
function facebooklink_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state)
{
//This gets the view_mode where our settings are stored
$display = $instance['display'][$view_mode];
//This gets the actual settings
$settings = $display['settings'];
//Initialize the element …Run Code Online (Sandbox Code Playgroud) drupal drupal-7 drupal-field-api drupal-fields drupal-modules
我想以编程方式创建自定义内容(通过管理UI创建的自定义内容).但是,在创建之前,我想以编程方式检查自定义内容的字段类型
我的自定义内容包含字段"body"(类型文本),字段"description"(类型文本),int字段(类型int),附加文件字段(类型fid?)...
我用Drupal 8的新api测试了几种方法,我的最后一次尝试..
// I get the entity object "my_custom_content"
$entity_object = NodeType::load("my_custom_content");
dpm($entity_object); //Work perfectly
$test = \Drupal::getContainer()->get("entity_field.manager")->getFieldDefinitions("my_custom_content",$entity_object->bundle())
//The \Drupal::getConta... Return an error : The "my_custom_content" entity type does not exist.
Run Code Online (Sandbox Code Playgroud)
使用此$ entity_object,如何获取自定义内容的字段列表?我看到了EntityFieldManager类,FieldItemList类......但我仍然不明白如何玩drupal 8/class/poo ...:/
谢谢 !
我为Drupal 8创建了一个自定义模块,该模块允许用户选择一种Content类型,以便以编程方式添加一些字段。如何创建一些字段(在这种情况下为文本类型),并使用自定义模块将它们附加到内容类型?
一些帮助?
谢谢。
我想知道如何在drupal 7中添加日期字段类型.我正在关注视频教程,当我注意到我的选择选项中没有"日期"字段类型.我该怎么做?

我本质上是尝试使用新的Drupal 7 Field API创建我的第一个字段类型模块.我设法让它在"编辑"视图中正确显示.
但是,当我尝试保存一些数据时,它只保存第一个字符.
这是模块:
<?php
function youtubefield_field_info() {
return array(
'youtubefield_video' => array(
'label' => t('Youtube video'),
'description' => t('This field stores a youtube video ID and displays the video associated with it'),
'settings' => array(
'max_length' => 11,
),
'instance_settings' => array(
'text_processing' => false,
),
'default_widget' => 'youtubefield_video_widget',
'default_formatter' => 'youtubefield_video_formatter',
),
);
}
function youtubefield_field_widget_info() {
return array(
'youtubefield_video_widget' => array(
'label' => t('Default'),
'field types' => array('youtubefield_video'),
),
);
}
function youtubefield_field_widget_form(&$form, &$form_state, $field, …Run Code Online (Sandbox Code Playgroud) 我从buildForm函数创建了一个自定义表单.在这种形式,我想添加一个图像字段.
我可以通过这段代码来做到这一点:
$form['main']['image'] = array(
'#type' => 'text_format',
'#title' => t('image'),
'#default_value' => array(10),
);
Run Code Online (Sandbox Code Playgroud)
我可以上传和删除表单中的图片.但是,当我上传图片时,我没有预览.我的意思是,当我通过Drupal UI创建内容时.我可以添加一个预配置的"图像"字段.当我通过这个"图像"字段上传图像时,我预览了图像.
在这里,当我以编程方式创建field元素时,我上传她时没有预览图像.当我通过"图像"字段上传她时,如何使用api Drupal进行图像预览?
我可以在注册时添加一个额外的字段.我需要知道的是我需要采取什么步骤来获取输入并将其插入到drupal的用户表中.下面的代码在我的模块中,它只为表单添加一个字段,但是当它提交时它不会对数据做任何事情.
function perscriptions_user($op, &$edit, &$account, $category = NULL){
if ($op == 'register') {
$form['surgery_address'] = array (
'#type' => 'textarea',
'#title' => t('Surgery Address'),
'#required' => TRUE,
);
return $form;
}
if ($op == 'update') {
// …
}
}
Run Code Online (Sandbox Code Playgroud) 给定"field_priority"字段的以下选择列表,如何在给定密钥(例如0,1,3)的情况下显示标签?
0|Low
1|Medium
2|High
3|Urgent
Run Code Online (Sandbox Code Playgroud) 我想开发一个模块,在drupal 7中为用户配置文件添加字段,如电话号码和CV ......我不知道该怎么做(使用数据库或使用字段API)请帮助我.
任何明确的教程将不胜感激.
drupal-fields ×10
drupal ×7
drupal-7 ×5
drupal-8 ×3
php ×2
cck ×1
date ×1
drupal-6 ×1
drupal-forms ×1
drupal-nodes ×1
union ×1
views ×1