If you have a form that is displayed in the overlay and in the submit handler you do:
$form_state['redirect'] = array(
'node/5',
array(
'fragment' => 'somewhere',
);
);
The overlay will close and node/5 will be reloaded but without the fragment and you won't be at the right place on the page.
The cause is, if I understand everything correctly, this:
* The redirect from the form passes through overlay_drupal_goto_alter()
which adds render=overlay to the url.
* The new page is requested (but the fragment is never sent by the browser) and passes through overlay_init()
.
* overlay_init()
gets to
elseif (!path_is_admin($current_path)) {
overlay_close_dialog($current_path, array('query' => drupal_get_query_parameters(NULL, array('q', 'render'))));
}
?>
which issues another redirect but here the fragment is lot forever since you cannot access the fragment part on the server side.
So we either need:
* a method for passing a fragment through the overlay redirects
* overlay_drupal_goto_alter() should detect that we're redirecting to a non-admin page and set $_SESSION['overlay_close_dialog'] directly.
Comments
Comment #1
alfaguru CreditAttribution: alfaguru commentedI saw this too, and the fix is seemingly straightforward, to add a check for overlay_paths_is_overlay() before adding render=overlay to the query. In my current project I have added a further implementation of hook_drupal_goto_alter, like this:
(This needs to run after overlay so you may need to add a hook_module_implements_alter() implementation as well.)
There might be unwanted side-effects in some cases, and clearly there's some extra overhead involved at this point but it also removes an unnecessary redirect so on the whole I would class it as an improvement. I am not sure how it will bear on the code related to authorize.php in overlay_drupal_goto_alter() so I haven't attempted a patch, though I am sure it would be simple.
Comment #2
alfaguru CreditAttribution: alfaguru commentedUnfortunately this code breaks other things, so would still hope for a fix to overlay.