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.
Can you add html text for the Flag fields?
At now we can set only link text.
For example, if we create comparison of products, I want to set text "This product is already in comparsion list [<a>compare</a>]. <a>Remove from comparison</a>
".
Comments
Comment #1
quicksketchYou can't currently do this through the interface, but you can do it by overriding the flag.tpl.php file. As you've demonstrated in your example, it's a challenge trying to provide some kind of syntax that makes sense for the links, since the user isn't going to know what the "href" property is going to be, you can't just use
<a>
wrappers.Comment #2
quicksketchThe issue in #301680: Create message: "Login to [flagname] [nodetitle]" has some interesting approaches to this problem. It simply allows HTML in the text directly but provides psuedo-tokens for !login and !register. We could do the same thing for something as simple as !url for the href value, so your flag text would look like this:
And the unflag text:
So you'd use the minus or plus symbols to do the actual flagging. Though using this approach, you'd need to use some tricky logic to inject the link description into the anchor tag (though obviously you could just type in the description directly into the anchor tag).
Allowing HTML in the link title would also worsen the problem described at #1138162: Raw tokens shown in UI for bulk operations and empty bookmarks page.
Comment #3
quicksketchMy suggestion at #1291670: Provide a live (iFrame) preview of various flag texts in action would help with this situation quite a bit.
Comment #4
joachim CreditAttribution: joachim commented