Skip to main content
10 events
when toggle format what by license comment
Jan 7, 2019 at 22:51 vote accept user1149499
Jan 5, 2019 at 8:41 history edited leymannx CC BY-SA 4.0
edited title
Jan 5, 2019 at 8:05 answer added leymannx timeline score: 0
Jan 5, 2019 at 7:33 history edited leymannx CC BY-SA 4.0
deleted 57 characters in body; edited title
Jan 5, 2019 at 1:08 comment added user1149499 @Kevin, thanks for sticking with me on this. Is there a way to implement this that's relatively newbie friendly? I've heard of hooks as a term but have never used them. Where's the best place to start? Also, in your comment, the "pretty easy with..." can you give me the syntax for how this would be done? Are you talking about something within a .theme file? Or (inadvisable as it may be) doing it on the page itself. If so, I think the "list field" part might be what I'm missing -- how do I do that part? Again, thank you in advance for any additional info/help!
Jan 5, 2019 at 1:07 answer added Kevin timeline score: 2
Jan 5, 2019 at 0:56 comment added Kevin Keeping php code in the database is bad practice and never advised. This is pretty easy with one list field and a switch statement
Jan 5, 2019 at 0:27 comment added user1149499 Thank you, Kevin. I am fairly new...was hoping to do this in the node Content itself using php. Is that just silly? Impossible? Alternately, is there a good place to start learning what a preprocess_hook is and how to use it? My other alternative would be to split the field into its various values and just do it binarily -- "if exists, rewrite the background-image" otherwise display none. If that's easier in my case, I could opt for that. It would suck to add 6 fields into the node but I don't have thousands of nodes...30 or 40 or so. If that's the easiest, I'll do it that way.
Jan 5, 2019 at 0:12 comment added Kevin You can’t do php in a twig file. The proper way to do this is set the icon value from a preprocess_node hook in the .theme file.
Jan 5, 2019 at 0:04 history asked user1149499 CC BY-SA 4.0