Problem/Motivation
Hi there, I'm trying to convert the values returned from a field into another text to display...
field returns ids: 1, 2, 3 and 4
So I need to replace:
if {{1}} then "apple";
if {{2}} then "banana";
if {{3}} then "kiwi";
if {{4}} then "orange";
So in a table would show like
| banana | blahblah |
| kiwi | blahblah |
| apple | blahblah |
| orange | blahblah |
| kiwi | blahblah |
| orange | blahblah |
etc....
How can I achieve that change, thanks a lot!
Comments
Comment #2
andrés chandía commentedComment #3
viren18febs commentedWorking on it!
Comment #4
andrés chandía commentedThanks a lot!!!!
Comment #5
viren18febs commentedHI @Andrés Chandía
Please refer this code sample, As per the twig template, we need to apply the for loop first & then add these
conditions into the loop.
Comment #6
andrés chandía commentedThanks a lot viren18febS, and sorry for my ignorance...
but can you explain me in detail what you mean by
Comment #7
viren18febs commentedYou need to create the twig file first & then use above code into the twig file for replacing the values.
Comment #8
smustgrave commented@Andrés Chandía does that answer your question?
Comment #9
andrés chandía commentedSorry, I'm learning about twig thing to be able to carry out the solution given by viren18febS
Thanks for asking...
Comment #10
smustgrave commentedNo worries going to mark this answered in the meantime
Here's more links that may help
https://www.drupal.org/docs/develop/theming-drupal/twig-in-drupal
Comment #11
andrés chandía commentedTnx!
Comment #12
andrés chandía commentedHi viren18febS, I'm sorry but I don't seem to be able to achieve this, due to my lack of experience of course...
I could find that the twig file managing the cell I need to modify is:
views-view-field.html.twigSo I found this file and copied it to
themes/d8w3css/templates/views/where I edited it by adding the following html code along with the code you developed as shown below, whatever I put in the div has effects for all the fields in the table, but modifying the 'vid' value does not, I'm sure I'm doing something wrong, so I'm asking for a little help on this:Thanks a lot!!