function pathauto_form_alter in Pathauto 5.2
Same name and namespace in other branches
- 5 pathauto_node.inc \pathauto_form_alter()
- 6.2 pathauto.module \pathauto_form_alter()
- 6 pathauto.module \pathauto_form_alter()
Implementation of hook_form_alter().
This allows alias creators to override Pathauto and specify their own aliases (Pathauto will be invisible to other users). Inserted into the path module's fieldset in the node form.
File
- ./
pathauto.module, line 255 - Main file for the Pathauto module, which automatically generates aliases for content.
Code
function pathauto_form_alter($formid, &$form) {
// Only do this for node forms
if (isset($form['#id']) && $form['#id'] == 'node-form' && arg(0) == 'node') {
// See if there is a pathauto pattern or default applicable
$pattern = trim(variable_get('pathauto_node_' . $form['type']['#value'] . '_pattern', FALSE));
if (!$pattern) {
$pattern = trim(variable_get('pathauto_node_pattern', FALSE));
}
// If there is a pattern AND the user is allowed to create aliases AND the path textbox is present on this form
if (!empty($pattern) && user_access('create url aliases') && isset($form['path']['path'])) {
$output = t('An alias will be generated for you. If you wish to create your own alias below, untick this option.');
if (user_access('administer pathauto')) {
$output .= t(' To control the format of the generated aliases, see the <a href="@pathauto">Pathauto settings</a>.', array(
'@pathauto' => url('admin/settings/pathauto'),
));
}
drupal_add_js(drupal_get_path('module', 'pathauto') . '/pathauto.js');
$form['path']['#collapsed'] = FALSE;
$form['path']['pathauto_perform_alias'] = array(
'#type' => 'checkbox',
'#title' => t('Automatic alias'),
'#default_value' => TRUE,
'#description' => $output,
'#weight' => -1,
);
}
}
}