Search code examples
phpdrupaldrupal-7

How to write the l link function


if the $text and the $path is a variable. how to write the l function. eg: the $text = $term->name , the $path = taxonomy/term/'.$term->tid how to write the l function. i used l($term->name,taxonomy/term/'.$term->tid)`. it doesn't work.


Solution

  • You've done everything right, but I think you have missed a single quote. Try to copy and paste the following code

    l($term->name, 'taxonomy/term/' . $term->tid);
    

    Update:

    If the l() function didn't display the path alias automatically, you can use drupal_get_path_alias() to get the path alias.

    l($term->name, drupal_get_path_alias('taxonomy/term/' . $term->tid));