Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The taxonomy_dhtml.module exports a block for each vocabulary which has a link for each term. These links may nest arbitrarily deep, just like our taxonomy.module. The theme_item_list()
function is great for displaying a set of items, but it assumes all items are at the same depth level. This request is for theme_item_list()
to support nested items.
Comment | File | Size | Author |
---|---|---|---|
#19 | theme.inc_12.patch | 1.68 KB | David Lesieur |
#15 | theme.inc_10.patch | 1.67 KB | David Lesieur |
#13 | theme.inc_7.patch | 1.16 KB | David Lesieur |
#8 | theme_item_list.patch | 1.05 KB | moshe weitzman |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedI think that the admin/sitemap page has logic for ouputting an unordered list from an array of items with depth attribute. This logic could be re-used for this feature request.
Comment #2
JonBob CreditAttribution: JonBob commentedThe sitemap feature uses the heirarchy of the menu data to build the lists, not a depth attribute. Which is preferable? In the former case, we need to specify the data structure that the theme function would take (perhaps that output by taxonomy_get_tree?); in the latter, we need to pass depths along as well. When I needed this in a module before, I followed the second approach. The module added:
This was before the full transition to CSS; I overrode this in themes to provide a CSS-based solution anyway.
Comment #3
moshe weitzman CreditAttribution: moshe weitzman commentedThanks JohnBob. However, the desired output is for an HTML unordered list, whereas your code produces a list using spaces as a'visual depth indicator'. I've updated the title of this request so this is clearer.
Comment #4
moshe weitzman CreditAttribution: moshe weitzman commentedBoris Mann submitted a brief patch which enables this. Please consider incorporating his patch into CVS.
I think Boris' approach is better than expecting a list as currently produced by taxonomy API (i.e. the 'depth' parameter).
Comment #5
moshe weitzman CreditAttribution: moshe weitzman commentedComment #6
Kjartan CreditAttribution: Kjartan commentedThe patch isn't prefect though. There are a few minor coding standard issues that need to be cleaned up, and it has to call theme('item_list') to make sure everything is styled properly. Also I am not sure of the array structure, is that really necessary?
Comment #7
moshe weitzman CreditAttribution: moshe weitzman commentedHere is an update of Boris' patch which applies cleanly to HEAD. Also, nested lists are properly themed and a few double quotes changed to single quotes.
You may test this patch with a custom php block containing:
Again, this will benefit the contributed taxonomy modules, weblinks.module and probably several others.
Comment #8
moshe weitzman CreditAttribution: moshe weitzman commentedthis time with patch attached.
Comment #9
Dries CreditAttribution: Dries commentedThe patch does not apply.
Also, Kjartan pointed out that
$item["list"]
might not be initialized. I suggest we use$list_type
instead. For sake of consistency,$theme["list"]
should probably betheme["items"]
. Lastly, the patch should be updated to respect Drupal's coding style.Comment #10
moshe weitzman CreditAttribution: moshe weitzman commentedComment #11
moshe weitzman CreditAttribution: moshe weitzman commentedanyone interested in writing this? would help clean up some contrib modules.
Comment #12
moshe weitzman CreditAttribution: moshe weitzman commentedComment #13
David Lesieur CreditAttribution: David Lesieur commentedHere is my attempt at this. It will be useful for this issue (and maybe others).
Comment #14
moshe weitzman CreditAttribution: moshe weitzman commenteddoes not apply anymore and theme_item_list() has changed slightly. please resubmit if possible.
Comment #15
David Lesieur CreditAttribution: David Lesieur commentedHere is an updated patch.
Comment #16
mathieu CreditAttribution: mathieu commentedTo the best of my knowledge, this patch respects the coding style and is simple enough. I just tested it out on drupal head and it still applies, with a -42 lines offset though.
+1.
Comment #17
moshe weitzman CreditAttribution: moshe weitzman commentedthanks mathieu.
Comment #18
drummneeds to be more explicit. How about
count($children) > 0
?Comment #19
David Lesieur CreditAttribution: David Lesieur commentedNew patch following drumm's comment. Since that was the only comment, I'm putting this back to its previous status "ready to be commited".
Comment #20
drummCommitted to HEAD.
Comment #21
(not verified) CreditAttribution: commented