The taxonomy_link() function in D6 has been improved so that new (i.e. non-existent) free-tagging terms are shown during node preview. That is, when you're submitting a new piece of content, and you type in some free-tagging terms that don't yet exist, those tags will be shown when you click 'preview'.

However, the typed-in name of each tag is being used as part of the key, for each element in the $links array that this function returns. Each key in the $links array is (for most themes) later outputted as a CSS class when the links are themed.

A tag's title is not suitable for being outputted as a CSS class, as it may contain spaces (which delimit CSS classes) and other unwelcome characters. I also don't think it's appropriate to shove a user-inputted string directly into the keys of an array, as a more general principle. Therefore, it would be better to simply assign an incremental number to each key in the array - this number will consequently be outputted in the CSS class name, instead of the tag's title.

This is hardly a big deal, as the array keys shouldn't be affected by spaces or other non-alpha-num characters, and as the CSS classes will never actually be used by themers (since the class names are generated once-off, on-the-fly, purely for node previewing). Nevertheless, I still consider it a bug.

Ideally, these links should all be output with the same class - 'taxonomy_preview_term' - instead of 'taxonomy_preview_term_x'. That way, they'd actually have an identifiable class that themers could target. But that's not possible at present, since hook_link() takes each array key and uses it as a class name, and there's no way to override this behaviour. Anyway, that's a separate issue.

Attached patch replaces the use of the tag title with a generated numeric ID.

Comments

Jaza’s picture

This patch also applies to DRUPAL-6 (with offset), and I think that it should be committed there as well.

lilou’s picture

Status: Needs review » Needs work

Patch no longer applied.

kars-t’s picture

Version: 7.x-dev » 6.x-dev
Assigned: Jaza » Unassigned
Priority: Normal » Minor
Status: Needs work » Needs review
StatusFileSize
new911 bytes

I believe this patch was made before D7 moved to field API. This doesn't apply to field API at all as the terms are rendered completely different.

But if I took a look at D6 and this still applies. This is a reasonable idea to not use the term names but an index. I don't remember if an index variable always should be something like $i so I leave this as it is and add a renewed version of the patch. And I move this into the D6 Issue queue where I believe it belongs to. As this Issue is years old I say this is a minor problem.

Status: Needs review » Needs work

The last submitted patch, freetag_link_preview_229642-v02.patch, failed testing.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.