| Versions | |
|---|---|
| 4.7 – 5 | path_form_alter($form_id, &$form) |
| 6 | path_form_alter(&$form, $form_state, $form_id) |
Implementation of hook_form_alter().
modules/
<?php
function path_form_alter($form_id, &$form) {
if (user_access('create url aliases') && isset($form['type']) && $form['type']['#value'] . '_node_form' == $form_id) {
$path = $form['#node']->path;
$form['path'] = array(
'#type' => 'fieldset',
'#title' => t('URL path settings'),
'#collapsible' => TRUE,
'#collapsed' => empty($path),
'#weight' => 30,
);
$form['path']['path'] = array(
'#type' => 'textfield',
'#default_value' => $path,
'#maxlength' => 250,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('Optionally specify an alternative URL by which this node can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
);
if ($path) {
$form['path']['pid'] = array(
'#type' => 'value',
'#value' => db_result(db_query("SELECT pid FROM {url_alias} WHERE dst = '%s'", $path)),
);
}
}
}
?>