function nodeblock_form_alter in Nodeblock 6
Same name and namespace in other branches
- 5 nodeblock.module \nodeblock_form_alter()
Implementation of hook_form_alter().
File
- ./
nodeblock.module, line 21 - Enables use of specified node types as custom blocks.
Code
function nodeblock_form_alter(&$form, $form_state, $form_id) {
// content type settings form
if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
$form['workflow']['nodeblock'] = array(
'#type' => 'radios',
'#title' => t('Available as block'),
'#default_value' => variable_get('nodeblock_' . $form['#node_type']->type, 0),
'#options' => array(
0 => t('Disabled'),
1 => t('Enabled'),
),
'#description' => t('Should these nodes be made available as blocks?'),
);
}
elseif (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) {
$node = $form['#node'];
// Add translation fallback field for nodeblock and translation enabled source nodes only
if (nodeblock_type_enabled($node->type) && module_exists('translation') && translation_supported_type($node->type) && empty($node->translation_source)) {
$form['nodeblock'] = array(
'#type' => 'fieldset',
'#title' => t('Block translation options'),
'#tree' => true,
);
$form['nodeblock']['translation_fallback'] = array(
'#type' => 'checkbox',
'#title' => t('Enable translation fallback?'),
'#description' => t('If checked, the source translation node will be used when a translation for the current language does not exist. If unchecked, the block will not be displayed if a matching translation does not exist.'),
'#default_value' => $node->nodeblock_translation_fallback,
);
}
}
}