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.
Sorry for a lack of a better title..
I have a flag with (un)flag text using tokens, ie, "Bookmark this [node:content-type:name]", so it's more user-friendly. The problem is that I get that label on the bulk operations at /admin/content and, even worse, when you visit /bookmarks and have no bookmarks, it says "You have not yet bookmarked any content. Click the "Bookmark this [node:content-type:name]" link when viewing a piece of content to add it to this list.".
I can see how this could be really hard to fix.. best move to just not use tokens?
Comment | File | Size | Author |
---|---|---|---|
#6 | flag-clear-empty-tokens-1138162-06.patch | 617 bytes | jhedstrom |
Comments
Comment #1
quicksketchI agree with this assessment, it's certainly not pretty to have tokens displayed without replacements. Perhaps we could strip out tokens entirely (anything that is in square brackets) in these situations?
Comment #2
quicksketchI'd like it if #1256012: Allow html text instead of plain link text could be implemented, as I find myself doing this sort of thing regularly (using HTML in the links), but if that were done, the Flag link text and the batch operation text would become entirely separate things.
So, another alternative (as always) is making more text fields in the Flag configuration. Perhaps something like "Flag action text" and "Unflag action text".
To help with this situation, I'd like to get something like #1291670: Provide a live (iFrame) preview of various flag texts in action implemented.
Comment #3
joachim CreditAttribution: joachim commentedComment #4
jhedstromThe function that is eventually called,
token_replace()
, has aclear
option that will remove empty tokens. This patch adds that option.Additionally, since flag labels can contain HTML, yet node operation labels get passed into an HTML select list, this patch passes flag labels through
strip_tags()
to avoid escaped HTML tags appearing in the select list.Comment #5
joachim CreditAttribution: joachim commentedThe addition of the clear option looks good.
Though it does mean that site builders need to word their labels carefully, so that they make sense without the tokens.
As for the strip_tags(), are there not also circumstances in VBO where the labels can appear on checkboxes? At any rate, I'd rather that we took care of that in a separate issue please.
Comment #6
jhedstromRe-rolled #4 with just the token logic. I've created #2201703: Strip HTML in hook_node_operations() with the strip_tags patch.
Comment #7
joachim CreditAttribution: joachim commented> when you visit /bookmarks and have no bookmarks, it says "You have not yet bookmarked any content. Click the "Bookmark this [node:content-type:name]" link when viewing a piece of content to add it to this list.".
Will the patch actually fix this case?
I see that this text is constructed in the view definition using the raw string from the flag object:
Comment #8
joachim CreditAttribution: joachim commentedComment #9
jhedstromRe: #7 I don't think it will fix that token, since it would just strip out the empty token.