I have panel, where I have argument: taxonomy term name

term names are transliterated (like "My custom taxonomy title" into my-custom-taxonomy-title)

path is like this: my-custom-list-of-nodes/my-custom-taxonomy-title

How can I get in PHP code (in some hook) original taxonomy term name from argument "my-custom-taxonomy-title"?

Original string can have diacritics, uppercase, spaces. How can I detect Term ID from transliterated argument "my-custom-taxonomy-title" ?

  • Since you have the term as an argument it will be available in your list of Contexts. In the context you will find the id and the original title. If you simply want to print the original term title, use Context keyword substitutions in a custom content pane. Commented Aug 10, 2014 at 14:48
  • thanks, but i need to use term ID in hook, not in content pane. I tried to use function menu_get_item but there is "context" key, but contains only "0". Commented Aug 10, 2014 at 15:12
  • What is it you are trying to do? Commented Aug 11, 2014 at 6:55

1 Answer 1


Short answer:

You can't do what you are asking.

Why is that?
While transliterating is a pretty simple procedure that follows a very specific number of steps:
- Replace every character with the corresponding-transliterated version
- If the resulting URL exists, add a -{Insert Number here} at the end until you find a URL that does not exist

reversing the transliteration is not that easy. Think of the extreme case where 5 different nodes/terms/entities have the exact same title. Their transliterated paths would be: /common-title /common-title-0 /common-title-1 /common-title-2 /common-title-3.

In this case, how do you know which transliterated title corresponds to each entity? Creation date (first one created gets the smallest index)? Besides the fact that this is extremely complex to predict, there may still be problems if a path was updated manually or one of the entities was deleted and a new one was added.

Long answer:

Even though what you are asking is not feasible, you can use a number of different approaches in order to solve the specific problem that you are facing.

Possible Solution 1:
You can use the current_path function. This will return the unaliased path of the currently viewed Drupal page. I am not exactly sure how the panels' pathing system works, but there is a very good chance that you will get something with the term id in it (that's what you need in your hook, right?).

In order to investigate this further in your code, assuming you have devel installed, you can do something like:


Possible Solution 2:
If the above-mentioned solution does not work, you will need to do some more digging in order to figure out which variables are available. Something that can get you started is a simple:


Depending on the results that you will get, you may be able to find the term name somewhere in the defined variables and use taxonomy_get_term_by_name() function to retrieve the tid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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