It appears that the module is working in that the heading of the sub-term is indented. However, it is indented via lineage_handler_field.inc, at line 20:
// output pseudo-link (without href) with hierarchically indented term and full path via title/alt-rollover
return str_repeat(' ', substr_count($content, "\n")-1)
. '<a title="' . $s . '" alt="' . $s . '">' . $a . '</a>';
Using   does not allow for any unique styling to sub-terms. I would like to output CSS, along these lines:
// output sub-term as title with span class for CSS modification
return str_repeat('', substr_count($content, "\n")-1)
. '<span class="term-level-#">' . $a . '</span>';
Where "#" is the level of the term (1, 2, 3). This allows me to style this term via CSS.
It appears that the field handler is removing the depth of the term. I cannot figure out how to get the level in the code.
Any help on this?
maria
Comments
Comment #1
mariagwyn commentedany suggestions or help on this? It would be a very helpful addition to this module since using ' ' offers no styling options.
Comment #2
xjmTracking. The oodles of
mostly get in the way and seem to interfere with the sorting order when sorting by hierarchy. Wouldn't it make more sense with Views 2 to simply include the raw lineage, with no markup, and then let the user override the markup as appropriate?mariagwyn: I think you want to take a look at adding a Term: Depth field in your view. Add this field, but exclude it from display, and you can use it with the "Rewrite the output of this field" checkbox for another field. This will give you a number you can then use in your CSS. E.g., you might have fields:
Node: Title
Taxonomy: Depth
Taxonomy: Term
You'd check "Exclude from display" for the term depth and "Rewrite output" for the term, using something like the following override template:
<span class="term-level-[depth]">[name]</span>(Note that "name" is the default token for the taxonomy term.)
Comment #3
xjmMarking as feature request.
Comment #4
mariagwyn commentedI ended up solving the problem with views in much the same way xjm suggested. It required a patch however, since the views 'group-by' was not allowing me to style the field using tokens. See: http://drupal.org/node/502348#comment-2155496
It is a worthy feature request here so that this module can be more effective on its own.
Comment #5
xjmThis patch adds a primitive formatting option form so that the user can select either the raw (linebreak-delimited) format for the lineage (presumably for use in a custom style plugin), or the original "pseudo-link" format that's been used to date. It will default to the original format if the format is undefined, so that there's not unexpected results with views created prior to applying this patch.
I'm marking this "needs work" because it would be more useful to have a more sophisticated formatting form with options like:
[ ] Strip weights
[ ] Machine-safe (for CSS class names, etc.)
Term prefix: ______________ (append before each term name in the lineage)
Term suffix: ______________ (append after each term name in the lineage)
Delimiter between terms: __________ (use
\nfor line breaks)Note that #507472: Fix weight string handling for D6 is relevant to this as well.
Comment #6
xjmPatch with proper naming convention, sorry for double post.
Comment #7
xjmThis version of the patch should work with patch in #3 in #507472: Fix weight string handling for D6.
Comment #8
praseodym commentedHere's a new patch for the current dev build which also adds a 'Path' option which outputs the taxonomy path for usage in e.g. exports.
It also fixes one translation issue in lineage.views.inc.
Comment #9
xjmPatch in #8 seems to leave hyphens at the beginning of term names in the "path" and "pseudo-link" handler options. (The raw is fine.) The problem is in the regex. Edit: compare below.
versus
Note that the proposed handler option set in #5 would also allow for a "path" option like the one available in #8 (the user could check "strip weights" and use " / " as the separator).
Comment #10
praseodym commentedI actually removed the hyphen in the regex because it didn't work: weight numbers were left in place. With the regex as it is in patch #8, it works and no hyphens are left behind.
Comment #11
xjmOdd, I get the hyphens left behind with #8 and a fresh download of 1.x-dev. Have you disabled and re-enabled lineage since upgrading to the November dev build? (This forces lineage to re-generate the weight strings using the new format). Edit: see #507472: Fix weight string handling for D6 for more information.
Also, could you post an example of the "raw" output for one of your term lineages? Thanks in advance.
Comment #12
xjmI think it's probably a better idea to refactor and add a
lineage_strip_weights()function that undoes what is done when the weights are appended, whatever form they are in. We also need to strip the weights in other contexts (like #612908: Add lineage nested list style plugin).Comment #13
xjmCreated #699198: Add lineage_strip_weights() and refactor field handler to use this function to address #12. Once that issue is resolved, I'll look into improving the field handler.
Comment #14
xjmComment #15
xjmComment #16
xjmThe attached patch is against the current dev build (Feb. 04 2010) and implements the formatting options described in #5. These options should allow anything from a simple raw format to a sophisticated use of the lineage with the "rewrite output of this field" options.
Note:
Edit: How to get the path via pseudo-link hover using this patch:
<a alt="[lineage]" title="[lineage]">[name]</a>(Substitute the appropriate tokens if yours differ.)
Comment #17
xjmCommitted to dev branch.