Skip to main content

Link

Drupal l() and url() methods

Submitted by amitsedai on
Both l and url methods are handy to create urls for various entities. However, the variety of options available makes the usage exciting and complex. l(): Formats an internal or external URL link as an HTML anchor tag. Syntax: l($text, $path, array $options = array()) Creating an absolute URL using l(). The example below creates a node link. <?php l(t('New product'), 'node/123', array('absolute' => TRUE)); ?> Add the previous url or the current page url before going to the new page.