Generating links that open in new pages with Drupal

Submitted by kitt on Thu, 2005-05-12 05:00.

Creating links that open pages in a new window is very easy with drupal

To generate a link with drupal, use the method l (that's a lowercase L):

$output .= l('Link text', 'desired/path/for/link');

Optional values include an attributes array:

l($text, $path, $attributes = array());

You can include a target value in this attributes array. In HTML, the target is the name of the window. If you use _blank, a new window will open:

$output .= l('Text link', 'my/path', array('target' => '_blank'));

This will produce the HTML:
<a href="my/path" target="_blank">Text link</a>