Language
  • English
  • Français
Drupal custom theming or module development price estimate calculator

Question about l() function

Hi,Aaron
Would you like to tell me more about :"http://www.pixelclever.com/how-and-why-use-l-function-create-links-drupal-programming"?

as that:

which file should I put the following code into? :

l($text, $path, $options = array())
or the example: print l('This is the link text', 'node/2');

$options = array(
'attributes' => array(),
'html' => TRUE,
);
l('', 'node/1', $options);

should I type the code in the page.tpl.php or the others?

The l() function can be used

Aaron's picture

The l() function can be used anywhere that php can be used within Drupal. That means from within any module, within template.php, or any include file that gets called by a module or theme. It basically is just a replacement for doing something like this:

$output = '<a href="/some-example-link" class="example-class">'.$some_dynamic_content_here.'</a>';
print $output;

Using l() insures that the link starts from the correct context (starting from the base path) and it adds active classes and other information that you wouldn't want to have to calculate on your own.

Poster un nouveau commentaire

Le contenu de ce champ sera maintenu privé et ne sera pas affiché publiquement.
  • Tags HTML autorisés : <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Les lignes et les paragraphes vont à la ligne automatiquement.

Plus d'informations sur les options de formatage

Ask a question related to Drupal development or administration