Пока нет стабильного релиза модуля Better Formats, можно воспользоваться следующим кодом, для создания своего модуля, который будет устанавливать значения формата ввода(Full HTML, Filtered HTML, PHP и т.д.) в зависимости от типа материала(Article, Basic и т.д.).
Содаем модуль:
- Создаем папку modulename
- Создаем файл modulename.module (например default_text_format.module)
/**
* Implements hook_element_info_alter().
*
* Sets the text format processor to a custom callback function.
* This code is taken from the Better Formats module.
*/
function default_text_format_element_info_alter(&$type) {
if (isset($type['text_format']['#process'])) {
foreach ($type['text_format']['#process'] as &$callback) {
if ($callback === 'filter_process_format') {
$callback = 'default_text_format_filter_process_format';
}
}
}
}
/**
* Callback for MODULENAME_element_info_alter().
*/
function default_text_format_filter_process_format($element) {
$element = filter_process_format($element);
// Change input format to "Filtered HTML" for body fields of article nodes
if ($element['#bundle'] == 'article' && $element['#field_name'] == 'body') {
$element['format']['format']['#default_value'] = 'filtered_html';
}
return $element;
}
- создаем файл modulename.info(например default_text_format.info)
; comments starting from semicolon(;) character
; default_text_format.info:
name = Default text format
description = Adapt the module code to set a default format for a content type.
package = Custom modules
core = "7.x"
Категория:
Добавить комментарий