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.
Please find attached the patch of my rewrites to views_plugin_style_lineage_nested.inc with the following changes:
- Added theme support. I've changed nested_list() so that it calls the Views theme in its recursion. Instead of going straight to output, the
return
from nested_list() copies over the existing array element (so Array objects are replaced with themed output strings). - As a result, I made rudimentary customisations to the default Views list template and attached it as views-view-lineage-nested.tpl_.txt. You'll obviously have to change _.txt in the file name to .php, but you can now copy and theme this in your own site theme.
- I moved the row rendering from render() to render_nesting(). This is to reduce the number of times which the taxonomy has to be looped through by 1.
- Because themes automagically handle headers, header() is obsolete (and removed).
- I changed variable names in render(), nested_list() and render_nesting() to make them more consistent with Views terminology. I hope this doesn't offend anybody.
- I figured out how to run render_nesting() so that it wouldn't have to call eval(). You're welcome.
- Miscellaneous changes I can't remember. Check the diff (also attached)
Note the comment around line 210
: @todo: remove this line once issue #1201054: Extra \n in term_lineage.lineage is resolved. This is to compensate for how the module stores information. This line of code will break the rendering once #1201054: Extra \n in term_lineage.lineage is fixed!!!
Comment | File | Size | Author |
---|---|---|---|
#4 | lineage-1201218-4.patch | 6.64 KB | xjm |
#3 | lineage-1201218-3.patch | 5.74 KB | xjm |
#2 | lineage-1201218-2.patch | 5.88 KB | xjm |
views_plugin_style_lineage_nested.diff | 5.73 KB | Anonymous (not verified) | |
views-view-lineage-nested.tpl_.txt | 736 bytes | Anonymous (not verified) |
Comments
Comment #1
xjmAwesome!
Marked #720984: Allow theming of lineage nested style plugin markup as duplicate.
Comment #2
xjmHere's a version of this patch rerolled against the current HEAD, using git, and with some trailing whitespace removed.
Edit: looks like there's some indentation issues as well--tabs or something?
Comment #3
xjmOther various cleanups.
Comment #4
xjm...And a patch that actually includes the new template file. Sorry for the noise.
Comment #5
xjmI tested this patch today with some existing views, and unfortunately it breaks them. I noticed in particular that nodes under the main term disappeared from the listing when a grouping was used.
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedThanks for following up. I'll look into it. The disappearing first term isn't at all related to issue #1201054: Extra \n in term_lineage.lineage, is it? My workaround may be creating an off-by-one error if the extra newline has been removed from the database.
Could I also have some sample output to help me trace the problem? A 'before patch' and 'after patch' HTML dump would be best.
Also, I use KWrite to edit PHP, so it may have turned my whitespaces into tabs. I'll check my settings but thanks for letting me know.
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedHas there been any more testing/review of my patch? Any inputs-outputs that I can use to debug?