0

I've installed Views along with the Internationalization views module. I have a view of users. The users have some single-value boolean fields in their profiles. I would like to rewrite the results of these fields so that if they are true an image and some text is shown.

Example: If "likes_soccer field is true, then show an image of a soccer ball with the words "Loves soccer"

This is quite simple to do in Views.

However, I also need to translate the text, and this is where I'm running into problems. Internationalization Views allows the text to be translated, but because it is HTML it ends up being sanitized so that the IMG tag is displayed as code rather than interpreted as HTML (as this answer explains). I can simply ignore the IMG tag in my translation, which will allow me to translate the text, but then I will lose the image in the translation.

Is there an alternative way to do this?

1
  • I'm not sure how much logic is involved in your setup, but I had quite a similar situation where I had to replace a field of type list (text) with a predefined image. I did it in the tpl file, using a switch statement. Would that be feasible in your setup? Commented May 13, 2012 at 18:34

1 Answer 1

0

I hit upon a very straightforward solution for doing this-- simply add each field that needs to be rewritten twice. Place the IMG tag in one field and the string to translate in the other. This way, no custom code need be written and everything can stay in Views.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.