louisstephens Posted January 4, 2016 Share Posted January 4, 2016 <?php if ($page->footerChecked->check == 1){ // 1 is checked, 0 is unchecked echo $page->footerSelect->footerPost; } else{ echo "Fail"; } ?> However, it still is posting "fail". Did I overlook something, or are checkboxes not supposed to be used this way. Sorry for any confusion: I have a template (storeFooter.php) which has 2 fields : footerChecked & footerPost. What I was trying to do was if the footerChecked was selected, display "footerPost". However, if it was not checked, display some random text. Link to comment Share on other sites More sharing options...
Pete Posted January 4, 2016 Share Posted January 4, 2016 I believe this is all you need: if ($page->footerChecked) { // true } else { //false } Link to comment Share on other sites More sharing options...
louisstephens Posted January 5, 2016 Author Share Posted January 5, 2016 Thanks Pete, Slowly learning more and more php as I go and definitely getting more comfortable with it. I appreciate all the help from a newbie. Link to comment Share on other sites More sharing options...
Pete Posted January 5, 2016 Share Posted January 5, 2016 No worries. It's not specific to PHP as you can't always guarantee a true or false response from the above code, just I know true or false is what is returned for PricessWire's checkbox values when using them in frontend templates. The actual printed value if you echo'd it would be a 1 I think if it was checked, else blank. It's always worth echoing a field to see what the actual value is, so echo $page->footerChecked in this instance.Other fields will return different values - some arrays of pages so let us know if you get stuck with anything else - there's plenty of help around the forums 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