theme_links()的用法

匿名 (未验证), 16 三月, 2010

theme_links($links, $attributes = array('class' => 'links'))

Return a themed set of links

Parameters

$links A keyed array of links to be themed.

$attributes A keyed array of attributes

Return value

A string containing an unordered list of links.

对$links的补充说明:

A keyed array of links to be themed. The key for each link is used as its css class. Each link should be itself an array, with the following keys:
- title: the link text
- href: the link URL.
     If omitted, the 'title' is shown as a plain text item in the links list.
- html: (optional) set this to TRUE if 'title' is already HTML.Array items are passed on to the l() function's $options parameter when creating the link.

一些例子:

$links =  array(
  'item1' => array( 'title' => '1st Item', 'href' => 'path/one' ),
  'item2' => array( 'title' => '2nd Item', 'href' => 'path/two' ),
);

 

仅返回列表(没有链接)

array( 'title' => '3rd Item')

完全自定义链接:
'item3' => array( 'title' => '<a href="http://example.com">link text</a>', 'html' => TRUE ),

评论