kaz Posted March 14 Share Posted March 14 A client would like to have a checkbox or similar for an image field in order to apply a style. echo " <img class='{$page->check}' src='{$page->image->url}'>"; I have thought about creating a checkbox, but it's not so easy because the class must given out in an echo. How to pass a class, a style in an echo? Link to comment Share on other sites More sharing options...
ngrmm Posted March 14 Share Posted March 14 @kaz you could store your class in a variable before echo // storing class in a variable $class = ($page->check == 1) ? "checkedClass" : "defaultClass"; // // or emtpy by default // $class = ($page->check == 1) ) "checkedClass" : ""; echo "<img class='$class' src='{$page->image->url}'>"; 1 Link to comment Share on other sites More sharing options...
kaz Posted March 15 Author Share Posted March 15 @ngrmm works great, thanks for the hint with a variable! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now