0

With my Drupal website ( which is much more custom than drupal ) I've got node referenced in another ( ex. an article in a custom page ).

I want the ability to easily edit the referenced content. To do that I've put a button with the link:

<?php print $base_url; ?>/node/<?php print $article->nid; ?>/edit?destination=<?php print urlencode('node/'.$node->nid); ?>

Sadly Drupal doesn't care about the destination and redirects me to the article node and not the current node it was into.

1

It is always a good habit to use l() to create links in Drupal. In your case, you can use the below code to create link.

l(t('Title'), 'node/' . $article->nid . '/edit', array('query' => array('destination' => 'node/' . $node->nid)));
0

Destination should work. If it doesn't then you could try this way using hook_form_alter to make it work.

function hook_form_alter(&$form, &$form_state, $form_id) {
        if($form_id == 'your_form_id') {
                $destination = $_GET['destination']; 
                $form_state['redirect'] = $destination;
        }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.