kaz Posted September 27, 2022 Posted September 27, 2022 I have a repeater field hero_items that I use for hero images. If no image is uploaded, an image field (settings_hero_image) from the global settings should be displayed. Unfortunately that does not work. The code for the data is correct. If the parts are single (hero_items or settings_hero_image) the images will be displayed. If no image is uploaded under hero_items, the browser code looks blank. Actually, else should now be displayed. If images are uploaded, the source code is correct. What is wrong with my if else query?
flydev Posted September 27, 2022 Posted September 27, 2022 Check with count($page->hero_items))instead of $page->hero_items as it return the field if it exist, not what's inside. 2
bernhard Posted September 27, 2022 Posted September 27, 2022 To debug such things TracyDebugger is extremely helpful! You could have just dumped $page->hero_items to the debug bar: bd($page->hero_items) ...and you would have seen what $page->hero_items was and why your if/else did not work ?
kaz Posted September 27, 2022 Author Posted September 27, 2022 @bernhard Good idea, but: I have tested TracyDebugger, it is too complicated for me.
kaz Posted September 27, 2022 Author Posted September 27, 2022 @flydev ?? unfortunately it did not work edit: a typing error, I revise: it works! if ($page->hero_items->count):
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