Views 2: Remove and markup from field rendering
mariagwyn - August 21, 2009 - 01:06
| Project: | Taxonomy Lineage |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
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

#1
any suggestions or help on this? It would be a very helpful addition to this module since using ' ' offers no styling options.
#2
Tracking. 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.)
#3
Marking as feature request.
#4
I 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.
#5
This 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.
#6
Patch with proper naming convention, sorry for double post.
#7
This version of the patch should work with patch in #3 in #507472: Fix weight string handling for D6.