Redirect to different url related to taxonomy depth

Summit - September 13, 2008 - 11:34
Project:Taxonomy Redirect
Version:5.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

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

#1

Justin W Freeman - November 14, 2009 - 03:50
Status:active» fixed

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

#2

Summit - November 14, 2009 - 12:13

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

#3

Justin W Freeman - November 14, 2009 - 13:02

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

#4

Justin W Freeman - November 14, 2009 - 13:04

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

#5

Justin W Freeman - November 14, 2009 - 13:06

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

#6

System Message - November 28, 2009 - 13:10
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.