Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

how do you check if a container field is empty?

Featured Replies

I am having trouble finding if a container field is empty or not.

In English:

If containerfield is not empty - get the image and display it.

Here is what I have (and does not work) in PHP

if($findData['Coverimage'][0] != '') { get the image }

-The field cover image is a container field.

-I can get the image without the if statement, however not all records have images.

Have you tried:

if($findData['Coverimage'][0] != NULL) { get the image }

  • Author

Thank you!

Pretty basic... but got it now.

  • Author

so... thought I had it... but

if($findData['Coverimage'][0] != NULL) { get the image } - works and records with images display correctly.

However, when I find some records that I think are NULL, it still tries to put an image there, giving a 'blank image' logo and the alt tag.

So I am back at square one.

ok...

Here is what you do in this case.

One of the geat things about php is that it allows you to break the code and write pure html then put the code back together.

Example:

<?php

if($findData['Coverimage'][0] != NULL) {

?>

<img src="<?php echo $findData['Coverimage'][0]; ?>">

<?php

}else{ ?>

no image...

<?php } ?>

Basically, I wrapped the PHP code around the HTML. So when it finds an image it will write a completely new html tag. If not, it will write "no image...".

Copy and paste the code above and you should see what I'm talking about.

I think that is what you are looking for.

~Addam~

  • Author

thank you for answering so quickly:

There are some errors in your code.

1.) echo $findData['CoverImage'][0]; will not work with container fields.

2.) Your code is essentially what I had and using old filemaker 5/6 code here it is:

<img src="http://localhost:591/FMPro?-db=Publication.fp5&-recid=<? echo $recid; ?>&Coverimage=&-img" alt="cover" width="134" align="right" hspace="8" vspace="5">

so... if you solve this, you are better than any filemaker PHP guru alive. So far an elite group of experts have been unable to cleanly and effectly show, test or use images from container fields in filemaker.

  • 1 month later...

Quite late on this one, but hey ...

What I do is create a calculation field in the database (checkImg) that checks to see if there is anything in the container field. If so, the calculation resolves to 1, if not, 0. Then I run the if statement on the checkImg field. Eg:

if ($findData['checkImg'][0] == 1) {

// display image;

}

Works like a charm.

Bear in mind I mostly use FX.php, which comes with a file (image_proxy.php) that handles the actual image display and retrieval with it's own syntax.

Cheers,

Kevin

  • 2 weeks later...
  • Author

I forgot to post an update to say what we did to solve things:

Basically Kevin's suggestion of a calculation field is the correct answer and it will work in FM5/6.

However for FM7, the image proxy is the only way to got, but the image proxy is very very clunky and doesn't work as well as we would like.

What would be great would be a simple php function that simply does the same as cdml without all the extra features of image proxy.

$getimage['fieldname']; // would return the image.

maybe someday we'll get this developed.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.