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?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

Title: Using tokens in the flag links ruin the UI for bulk operations and empty bookmarks page » Raw tokens shown in UI for bulk operations and empty bookmarks page

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

quicksketch’s picture

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

joachim’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev
jhedstrom’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
1.49 KB

The function that is eventually called, token_replace(), has a clear 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.

joachim’s picture

Status: Needs review » Needs work

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

jhedstrom’s picture

Status: Needs work » Needs review
FileSize
617 bytes

Re-rolled #4 with just the token logic. I've created #2201703: Strip HTML in hook_node_operations() with the strip_tags patch.

joachim’s picture

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

  $handler->override_option('empty', 'You have not yet bookmarked any content. Click the "' . $flag->flag_short . '" link when viewing a piece of content to add it to this list.');
joachim’s picture

Status: Needs review » Needs work
jhedstrom’s picture

Re: #7 I don't think it will fix that token, since it would just strip out the empty token.