robdecker
6/25/2013 - 11:16 PM

Drupal 7: Link l() function with attributes.

Drupal 7: Link l() function with attributes.

l(
  t('Link Title'), 
  'link_path', 
  array(
    'attributes' => array(
      'class' => array(
        'menu-link', 
        'another-class',
      ), 
      'id' =>'faq-page',
    ),
    'query' => array(
      'foo' => 'bar',
    ), 
    'fragment' => 'refresh',
    'html' => TRUE,
  ),
);
l(
  t('<span></span>Link Title'), 
  'link_path', 
  array(
    'attributes' => array(
      'class' => array('menu-link'), 
      'id' =>'faq-page',
    ), 
    'html' => TRUE,
  ),
);