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 &nbsp 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

mariagwyn’s picture

any suggestions or help on this? It would be a very helpful addition to this module since using '&nbsp' offers no styling options.

xjm’s picture

Title: Views 2: Remove &nbsp; and markup from field rendering » Use CSS to style term level outputs
Version: 6.x-1.x-dev » 6.x-1.0
Category: feature » support

Tracking. The oodles of &nbsp; 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.)

xjm’s picture

Title: Use CSS to style term level outputs » Views 2: Remove &nbsp; and markup from field rendering
Version: 6.x-1.0 » 6.x-1.x-dev
Category: support » feature

Marking as feature request.

mariagwyn’s picture

Title: Use CSS to style term level outputs » Views 2: Remove &nbsp; and markup from field rendering
Version: 6.x-1.0 » 6.x-1.x-dev
Category: support » feature

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.

xjm’s picture

StatusFileSize
new2.44 KB

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 \n for line breaks)

Note that #507472: Fix weight string handling for D6 is relevant to this as well.

xjm’s picture

Status: Active » Needs work
StatusFileSize
new2.44 KB

Patch with proper naming convention, sorry for double post.

xjm’s picture

StatusFileSize
new2.46 KB

This version of the patch should work with patch in #3 in #507472: Fix weight string handling for D6.

praseodym’s picture

Status: Needs work » Needs review
StatusFileSize
new3.25 KB

Here'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.

xjm’s picture

Status: Needs review » Needs work

Patch 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.

-    // split lineage string into pieces, i.e. hierarchial path (getting rid of weight numbers, too)
-    $path = preg_split("(\n[0-9]+-)", "\n" . $content);

versus

+      // split lineage string into pieces, i.e. hierarchial path (getting rid of weight numbers, too)
+      $path = preg_split("(\n[0-9]+)", "\n".$content);

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).

praseodym’s picture

I 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.

xjm’s picture

Odd, 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.

xjm’s picture

Title: Views 2: Remove &nbsp; and markup from field rendering » Views 2: Improve field handler and refactor for better weight string handling

I 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).

xjm’s picture

Title: Views 2: Improve field handler and refactor for better weight string handling » Views 2: Improve field handler
Status: Needs work » Postponed

Created #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.

xjm’s picture

Assigned: Unassigned » xjm
xjm’s picture

Status: Postponed » Needs work
xjm’s picture

Status: Needs work » Needs review
StatusFileSize
new4.2 KB

The 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:

  1. This patch will change the output of your existing views if you are using the old hover-link rendering. You should reconfigure the field options and possibly clear your views cache.
  2. This patch will expect the new weight string formats. If you upgrade from an older version of lineage to the current 6.x-1.x-dev, be sure to disable and re-enable the module to make Lineage generate the new strings. (See #507472: Fix weight string handling for D6 for more information.)

Edit: How to get the path via pseudo-link hover using this patch:

  1. Filter your view by Taxonomy: Vocabulary for your hierarchical vocabulary.
  2. Add a Taxonomy: Hierarchy field. Check Strip weights and set the Delimiter to " / ".
  3. Add a Taxonomy: Term field. Check Rewrite output of this field and enter something like the following in the Text box:
    <a alt="[lineage]" title="[lineage]">[name]</a>
    (Substitute the appropriate tokens if yours differ.)
  4. To control indentation or styling of the term, use the method described in #2 & #4 above, and/or try the patch in #612908: Add lineage nested list style plugin.
  5. You should probably also check "field can contain HTML" so that the appropriate text filter is applied.
xjm’s picture

Status: Needs review » Fixed

Committed to dev branch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.