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

quicksketch’s picture

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

quicksketch’s picture

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

Not flagged (<a href="!url">+</a>)

And the unflag text:

Flagged (<a href="!url">-</a>)

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.

quicksketch’s picture

My suggestion at #1291670: Provide a live (iFrame) preview of various flag texts in action would help with this situation quite a bit.

joachim’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev