2

I am new to Drupal. I am trying to figure out if it is possible to redirect back to the Taxonomy page right after adding the new vocabulary term instead of being directed to the manage page of the newly created term. Would this have to be changed in the controller for the taxonomy module? Or in another file?

Any help is appreciated, Thank You.

4
  • piece of cake, using the Rules module ... assuming you're talking about D7 (for now). – Pierre.Vriens May 2 '17 at 18:08
  • 1
    I'm using D8, is there another work around? – Zen May 2 '17 at 18:12
  • search into the taxonomy module to see how this works – Adrian Cid Almaguer May 2 '17 at 18:13
  • I am in the taxonomy module and in the TaxonomyController.php, I believe I should change the route from there, but I'm not sure which one or if I would have to create a new route. – Zen May 2 '17 at 18:16
0

To add a redirection after creating new Taxonomy Term I suggest using the hook_preprocess_HOOK() in the MYTHEME.theme file.

E.g. here is code that add redirection back to the Vocabulary - list of all terms - for the Add term button:

/**
 * Implements hook_preprocess_HOOK() for menu-local-action templates.
 */
function MYTHEME_preprocess_menu_local_action(array &$vars) {
  if ($vars['link']['#title'] == 'Add term') {
    // Add redirection to the Terms list after creating a new term.
    $destination = Url::fromRoute('<current>')->toString();
    $vars['link']['#options']['query']['destination'] = $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.