if else with images uploaded using code generator
5 posts by 2 authors in: Forums > CMS Builder
Last Post: October 23, 2015 (RSS)
By Twocans - October 22, 2015
hello,
I have been playing with the CMS code generator, and I am hugely impressed. I have a problem thought. When the user uploads an image I also have a check-box for them to click so as to show hide the big images were they in need to do so. The values are either 1, or 0
Check to Show Big Image (value): <?php echo $record['check_to_show_big_image'] ?><br/>
Check to Show Big Image (text): <?php echo $record['check_to_show_big_image:text'] ?><br/>
The code above the code generator creates but I have been trying to do an if else for that but get errors all the time.
anyway I have tried using an if statement with the following.
<?php if ($record['check_to_show_big_image']) > 0 ?>image shown here
<?php else: ?>No image shown
<?php endif ?>
It does not work.
I would be very grateful for any input on this to get it working.
regards and cheers
kenny
By Twocans - October 22, 2015
wow sorry,
<?php if ($home_page_big_imagesRecord['check_to_show_big_image'] == '1'): ?> ...my pics...
<?php endif ?>
the above works for me but hehe if its wrong let me know..
cheers
Kenny
By Daryl - October 22, 2015
Hi Kenny,
That's correct. Or you can do it this way too:
<?php if ($home_page_big_imagesRecord['check_to_show_big_image']): ?>
...my pics...
<?php endif ?>
Cheers,
PHP Programmer - interactivetools.com
By Twocans - October 23, 2015
Thanks another quick question on the upload.
I have use the code generator twice on the same page, aka for 2 different sets and both of these recordsets have images.
My problem is Calling these variables on my page as both are called "<?php echo htmlencode($upload['urlPath']) ?>
how can I get both to show as one is on the top of my page and the others are placed on the bottom of the page. But only can get the top ones to show due to <?php echo htmlencode($upload['urlPath']) ?> is the same for both ?
regards
kenny
By Twocans - October 23, 2015
Sorry about having posted this now as having been testing it all day I was tripping over myself
I see now how to have both appear on the page and that is by also using the repeat
<?php foreach ($home_page_bottom_left_imagesRecord['small_image_upload'] as $index => $upload): ?>
<a href="<?php echo htmlencode($upload['urlPath']) ?>" class="p7lsm_type_img">
<?php endforeach ?>
and
<?php foreach ($home_page_rotationRecord['big_image_upload'] as $index => $upload): ?>
<a href="<?php echo htmlencode($upload['urlPath']) ?>" class="p7lsm_type_img"> <<< I was adding the second call for upload like this but without the foreach thus
<?php endforeach ?>
so now i have learnt lol both need there own foreach.
have a nice weekend
kenny