Detailed description of how to use the l () function in Drupal

Source: Internet
Author: User
Tags drupal


L functions should be one of the most frequently used functions of Drupal developers. Another possibility is the t function.

No matter how awesome you are, I can only say that you may find the l function manual no less than 10 times.

Basic usage:

 
$ Title: title
$ Url: connection address
L ($ title, $ url)
Add class

 
L ($ title, $ url, array ('bubuckets' => array ('class' => array ('myclass '))));
Add id

 
L ($ title, $ url, array ('bubuckets' => array ('id' => 'myid ')));
Add target = _ blank

 
L ($ title, $ url, array ('bubuckets' => array ('target' => '_ blank ')));
Add # top

 
L ($ title, $ url, array ('fragment '=> 'top '));
Add parameters? Name = terry? Gender = male
 
L ($ title, $ url, array ('query' => array ('name' => 'Terry ', 'gender' => 'male ')));
Connect to js

 
L ($ text, 'javascript: void (0) ', array ('fragment' => '', 'external '=> true ));
Link to image

 
$ Image = theme_image_style (array ('path' => $ image_path, 'style _ name' => '100x100 '));
L ($ image, '', array ('html' => TRUE ));


The code snippet of cingda:

Global $ base_url;
Print
L (
' field_image ['en'] [0] ['uri ']).'"/> ',
$ Base_url. $ node_url,
Array (
'Bubuckets' => array (
'Id' => 'My-id ',
'Class' => 'My-class'
),
'Query' => array (
'Foo' => 'bar'
),
'Fragment '=> 'refresh ',
'Html' => TRUE
        )
);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.