Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
15 Feb 2012 at 12:35 UTC
Updated:
29 Feb 2012 at 17:00 UTC
API page: http://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_lin...
The documentation of use is not clear without an example. The function does not work as expected and does not return errors when tested with:
function MyModule_test()
{
$linklist = array(
'item1' => array( 'title' => '1st Item', 'href' => 'one' ),
'item2' => array( 'title' => '2nd Item', 'href' => 'two' ),
'item3' => array( 'title' => '3rd Item'),
array( 'title' => '4th Item', 'href' => 'four' ),
'item5' => '',
'item6' => array( 'title' => '6th Item', 'href' => 'six' )
);
$output = theme('links', $linklist);
return $output;
}
Comments
Comment #1
jhodgdonYou didn't follow the documentation. There is one argument $variables, which is an array with required element 'links', and optional 'heading' and 'attributes'. You passed in an array with elements 'item1', 'item2', etc.
Comment #2
carlmcdade commentedAs I said with the unclear wording and the syntax needed the documentation needs to have a working example. You'll never be able to explain this otherwise.
This works:
Should be something like:
And even that begins to fall short if not broken up with code examples.
Comment #3
jhodgdonWe don't generally add examples to the documentation itself -- there are plenty of examples of calls to theme('links') in the Drupal Core code already.
Feel free to add your example as a comment on that page, to aid others having the same difficulty.