Hi,
I would like to build a hierarchical website.
What I need is the possibility to set a different view redirect to the depth of the taxonomy/term.
So top taxonomy terms needs to be directed to view "in"
child of top taxonomy terms needs to be directed to view "in_region"
childs of these terms needs to be directed to view "in_place".

So the depth of the terms needs to be used to redirect accordingly.
Is this doable with taxonomy redirect? If not any suggestion how to get this most automated fixed?

Thanks in advance for your reply!
greetings,
Martijn

Comments

agileware’s picture

Status: Active » Fixed

You should be able to do this now by using PHP to create your redirects.

summit’s picture

Hi, thanks for your remark, can you give me please an example how to move further with php and this great module to get the following:
- first depth to country/term
- second depth to province/term
- third depth to city/term

Thanks a lot in advance!

greetings,
Martijn

agileware’s picture

Try this

<?php
  $parents = taxonomy_get_parents_all($tid);
  $depth = count($parents);
  if ($depth == 1) {
    return 'in';
  }
  elseif ($depth == 2) {
    return 'in_region';
  }
  elseif ($depth == 3) {
    return 'in_place';
  }
  else {
    return "taxonomy/term/$tid";
  }
?>

This should do what you want. It also covers any terms with depth outside your requirements by directing them to the normal taxonom/term/tid path

agileware’s picture

Create a redirect for the vocab you are using, without selecting any terms, and add that php code for the path.

agileware’s picture

Marked #451598: Redirect according to depth as a duplicate of this issue

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.