How do I get a node, or a taxonomy term URL knowing the node ID or the taxonomy term ID?

drupal.stackexchange https://drupal.stackexchange.com/questions/2668

  •  16-10-2019
  •  | 
  •  

Question

I need to render the full URL from a taxonomy term ID.

Was it helpful?

Solution

The generic way is this:

$uri = entity_uri($entity_type, $entity);
$url = $uri['path'];

So for a node, $entity_type would be 'node', and $entity would be the fully loaded node object.

Taxonomy terms are also entities in D7, so the syntax would be similar.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top