adrianmak Posted December 20, 2016 Share Posted December 20, 2016 i have an image field. A template accept one image file upload Another template has no number of image file limitation Instead of create two different image field of different field setting, is there any module add field extend to allow individual field settings for different template ? Link to comment Share on other sites More sharing options...
kongondo Posted December 20, 2016 Share Posted December 20, 2016 (edited) if($page->template == 'one-image-template') { if(!count($page->multi_image_field)) { // add image, none added yet } } else { // add as many images as you like } Edited December 20, 2016 by kongondo clearer code Link to comment Share on other sites More sharing options...
adrianmak Posted December 20, 2016 Author Share Posted December 20, 2016 8 minutes ago, kongondo said: if($page->template == 'one-image-template') { if(!count($page->multi_image_field))// add image, none added yet } else { // add as many images as you like } what is the purpose of the second if statement ? Link to comment Share on other sites More sharing options...
kongondo Posted December 20, 2016 Share Posted December 20, 2016 (edited) Checks if you already have an image in that image field. If count returns something, it means there's an image in the field already. It presupposes you've never added more than one image before. If its empty, you can add an image, if not empty, do something else. This is near-pseudo code so things can be changed around...Edited the code above for clarity Edited December 20, 2016 by kongondo clarity... 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