I’m super new to PHP and I’m just getting started with Kirby and trying things out.
I’m making a simple gallery using a list of images. I want to be able to toggle the css class of an image from the panel. My code is below but it’s not working, any help?
On a side note, its generally bad practice to put PHP inside an HTML attribute like that, it is much more readable to do it above and echo the result into the attribute.
On a side note: The reason why your code does not work is that while you correctly define the $class method with the desired value, you then do nothing with this variable.
I couldn’t get this to work but as I’m only switching between two classes I used the same logic I used a toggle and got it to work. If I had multiple radio options for multiple classes how would each radio trigger a different class?