function redirect_page_build in Redirect 7
Same name and namespace in other branches
- 8 redirect.module \redirect_page_build()
- 7.2 redirect.module \redirect_page_build()
Implements hook_page_build().
Adds an action on 404 pages to create a redirect.
File
- ./
redirect.module, line 469
Code
function redirect_page_build(&$page) {
if (redirect_is_current_page_404() && user_access('administer redirects')) {
if (!isset($page['content']['system_main']['actions'])) {
$page['content']['system_main']['actions'] = array(
'#theme' => 'links',
'#links' => array(),
'#attributes' => array(
'class' => array(
'action-links',
),
),
'#weight' => -100,
);
}
// We cannot simply use current_path() because if a 404 path is set, then
// that value overrides whatever is in $_GET['q']. The
// drupal_deliver_html_page() function thankfully puts the original current
// path into $_GET['destination'].
$destination = drupal_get_destination();
$page['content']['system_main']['actions']['#links']['add_redirect'] = array(
'title' => t('Add URL redirect from this page to another location'),
'href' => 'admin/config/search/redirect/add',
'query' => array(
'source' => $destination['destination'],
) + drupal_get_destination(),
);
}
}