0

我正在构建一个带有“项目”内容类型的 drupal 7 (7.20) 网站,其中包含多个图像字段(我不想使用画廊)。

我希望能够从节点编辑页面对这些字段执行批量删除操作。从我收集到的内容中,我必须覆盖 theme_file_widget_multiple 并返回一个 tableselect 而不是一个表,然后使用一个按钮和 javascript 从数据库中删除图像。

我错过了一些明显的东西吗?对于如此微不足道的事情,这似乎需要做很多工作。

编辑:

我在这方面取得了一些进展:

function mytheme_file_widget_multiple($variables) {

$element = $variables ['element'];
$headers = array ();
$headers ['info'] = t ( '' );

$widgets = array ();
foreach ( element_children ( $element ) as $key ) {
    $widgets [] = &$element [$key];
}
usort ( $widgets, '_field_sort_items_value_helper' );

$rows [] = array ();
$i = 0;
foreach ( $widgets as $key => &$widget ) {
    // Save the uploading row for last.
    if ($widget ['#file'] == FALSE) {
        $widget ['#description'] = $element ['#file_upload_description'];
        continue;
    }
    $operations_elements = array ();
    foreach ( element_children ( $widget ) as $sub_key ) {
        if (isset ( $widget [$sub_key] ['#type'] ) && $widget [$sub_key] ['#type'] == 'submit') {
            $operations_elements [] = &$widget [$sub_key];
        }
    }
    $information = drupal_render ( $widget );
    $rows [$i ++] ['info'] = $information;
}

$output = '';
$output = drupal_render_children ( $element );
$form ['element'] = array (
    '#type' => 'tableselect',
    '#header' => $headers,
    '#options' => $rows,
    '#js_select' => TRUE,
    '#empty' => t ( 'No data' ),
    '#attributes' => array () );
$output .= empty ( $rows ) ? "" : drupal_render ( $form );
return $output;
}

这包含在我的主题模板文件中,但是 tableselect 没有复选框。这让我发疯..有人可以告诉我我做错了什么吗?

4

1 回答 1

0

根据我收集到的信息,我必须创建一个覆盖字段集预处理函数的模块。

以下是参考资料:

1) https://drupal.org/node/1905244

这篇文章似乎试图做你想做的事。

2)另请查看https://drupal.org/project/views_bulk_operations 这可能有用。

3)如果没有,那么您将需要制作自己的小部件:

https://api.drupal.org/api/drupal/modules%21field%21field.module/group/field/7

https://drupal.org/project/examples(包含您需要的所有示例)

一切顺利。

于 2013-08-10T21:36:25.430 回答