Как включить вставку модуля в профиль установки?
Я хочу использовать модуль вставки для поля файла, но я не могу включить его программно. Есть ли параметр типа "вставить" => true или что-то в этом роде? Есть ли какая-либо документация об этих настройках, потому что я не могу найти никакой информации в Интернете?
2 answers
Вы можете включить вставку, обновив настройки экземпляра поля с помощью следующих двух основных функций:
Например:
/**
* Enable insert field settings
*/
function MODULE_field_settings_enable_insert($entity_type, $field_name, $bundle){
// Load field instance
$instance = field_info_instance($entity_type, $field_name, $bundle);
// Build insert settings array, these image styles are just examples
$insert_settings = array(
'insert' => 1,
'insert_absolute' => 1,
'insert_styles' =>
array (
'image_236w' => 'image_236w',
'image_237x147' => 'image_237x147',
'image_486w' => 'image_486w',
'colorbox__236w' => 'colorbox__236w',
'colorbox__237x147' => 'colorbox__237x147',
'colorbox__486w' => 'colorbox__486w',
'auto' => 0,
'link' => 0,
'icon_link' => 0,
'image' => 0,
'image_60x60' => 0,
'image_62x62' => 0,
'image_62x82' => 0,
'image_67x67' => 0,
'image_69x52' => 0,
'image_71x44' => 0,
'image_71x71' => 0,
),
'insert_default' => 'image_237x147',
'insert_class' => 'caption',
);
// Add the insert settings to the field instance widget settings
foreach($insert_settings as $key => $setting){
$instance['widget']['settings'][$key] = $setting;
}
// Save the field instance
field_update_instance($instance);
}
// Then you can enable insert on a field instance with
MODULE_field_settings_enable_insert('node', 'field_images', 'article')
Это довольно просто сделать, если вы устанавливаете Drupal с профилем установки.
Допустим, имя вашего профиля установки custom_profile
, просто добавьте следующую строку в файл custom_profile.info
, чтобы установить модуль вставки при установке Drupal:
dependencies[] = insert