Lists
Lists cover a wide range of use cases for Drupal's output from menus to content listings. There are numerous theme functions that output lists and parts of those lists. Unfortunately, this means a lot of theme functions to override when trying to provide a consistent experience. Ideally, we would have one theme function that takes care of outputting all lists, by satisfying the basic requirements that are common among most lists.
Examples
HTML source
<ul>
<li><a href="#">one</a></li>
<li><a href="#">two</a></li>
<li><a href="#">three</a></li>
</ul>
PHP source
<ul<?php print $attributes; ?>>
<?php foreach ($items as $item): ?>
<li<?php print $item['attributes']; ?>><?php print render($item); ?></li>
<?php endforeach; ?>
</ul>
HTML source
<ol>
<li><a href="#">one</a></li>
<li><a href="#">two</a></li>
<li><a href="#">three</a></li>
</ol>
PHP source
<ol<?php print $attributes; ?>>
<?php foreach ($items as $item): ?>
<li<?php print $item['attributes']; ?>><?php print render($item); ?></li>
<?php endforeach; ?>
</ol>
Requirements
- Provide optional helper classes to the
<ul>
and<li>
and children elements.- Provide
.active
class when child element links to the current path. - Provide
.active-trail
class when child element links to a parent of the current path.
- Provide
- Include HTML or Plain text in the
<li>
. - Ability to include nested lists and/or other nested content.
- Ability to determine whether the list contents container rendered children and what the current and total depth is.
- Ability to modify the default implementation per instance of the list, with theme hook suggestions or something similar.
See also: containers.