0

I'm setting up a search page by views exposed filter. And one of the field are filter by taxonomy term.

For example, when I search with the taxonomy term filter field, the URL is like below.

domain.com/search?subjects=69

Now I wish to get the value of the taxonomy (it's showing tid instead of value)

<?php
$idenity = $_GET['subjects'];
print $idenity;
?>

Anyway to get the value of the taxonomy value but not taxonomy id?

Kooki3
  • 599
  • 4
  • 12

1 Answers1

0

You didn't specify which version you're using so I'm assuming Drupal 7 because it's the latest stable version.

You can load the term with taxonomy_term_load():

<?php
$tid = intval($_GET['subjects']);
$term = taxonomy_term_load($tid)
print $term->name;
?>

Personally, I find that the comments on the Drupal API site are usually very helpful in understanding how to use functions that sound like they are relevant to my problem.

Sleavely
  • 1,654
  • 2
  • 11
  • 18
  • There's a similar function called taxonomy_term_load_multiple() that takes an array as argument. – Sleavely Jun 20 '14 at 09:36
  • tested, and looks like intval() is causing my page to crash – Kooki3 Jun 20 '14 at 09:39
  • intval() will not work with taxonomy_term_load_multiple(), no. That's because intval creates a single integer value. Doesn't work with arrays. Why did you unmark my original answer as correct to your original question? – Sleavely Jun 20 '14 at 11:28
  • as i tested and it gives me error for intval(). not with multiple load. – Kooki3 Jun 23 '14 at 02:18