5 Replies Latest reply on Mar 5, 2011 5:26 AM by FlorianWiegand

    FMS11 IIS PHP Publish and automatic date diff calculation if field not null

    FlorianWiegand

      Title

      FMS11 IIS PHP Publish and automatic date diff calculation if field not null

      Your post

      Dear all,

      i am building a database application for my team at work to manage parts of our project more effectively and organize my team. I started to build the application with file maker 11 and then ported it to the fms11 on server 08 r2 with iis.

      1. I have two date fields and one field that calculates the working day difference between the two. Eventough i have selected the option to not calculate if fields are empty, it calculates all fields and gives rubbish answeres on data sets which are empty. How can i get fmp11 to check if a field is full, and only then perform a calculation and do this every time i change a view or dataset in the layout?

      2. I have a "attachment" field with the field type "container" and a edit box in the layout. I can see the attachments such as pictures in the layout view but if a publish it with the php publisher to the iis, i can see the picture if its present and all others a large rectangle with a red x in it. How can i get rid of the red x and empty box?

      Thank you for all your help

      Florian

        • 1. Re: FMS11 IIS PHP Publish and automatic date diff calculation if field not null
          philmodjunk

          1. I have two date fields and one field that calculates the working day difference between the two. Eventough i have selected the option to not calculate if fields are empty, it calculates all fields and gives rubbish answeres on data sets which are empty. How can i get fmp11 to check if a field is full, and only then perform a calculation and do this every time i change a view or dataset in the layout?

          I don't think you are really getting a "rubbish answer" here, just not the value you expected when one date field is empty and the other is not. The option "Do not evaluate if all referenced fields are empty" won't affect the calculation if one field is empty and the other is not.

          Here's a calculation that returns null if either one of the two date fields are empty:

          If ( not ( IsEmpty ( date1  ) or IsEmpty (  date2  ) ) ; date2 - date1 )

          • 2. Re: FMS11 IIS PHP Publish and automatic date diff calculation if field not null

            Florian Wiegand:

            Thanks for posting!

            PhilModJunks solution should work perfectly for your first issue (thank you, PhilModJunk!). 

            Your second issue can be resolved by adding a little PHP to the browserecord.php page. First, find the three lines that look like this:

            <td class="field_data">

            <img src="<?php echo getImageURL(storeFieldNames('<your field name>', 0, $record, true, 'EDITTEXT', 'container'))?>">

            </td>

            This code is what actually displays the image to the user. We can add an if statement just before this so that it's not evaluated if it doesn't contain an image. The end result should look similar to this:

            <?php if(getImageURL(storeFieldNames('<your field name>', 0, $record, true, 'EDITTEXT', 'container')) != "img.php?-url=") { ?>

            <td class="field_data">

            <img src="<?php echo getImageURL(storeFieldNames('<your field name>', 0, $record, true, 'EDITTEXT', 'container'))?>">

            </td>

            <?php } ?>

            The last line is just terminating the if statement. Essentially, everything between the two lines we added will not be run at all if the getImageURL method gives us a value indicating no image.

            Let me know if you run into any trouble implementing this.

            TSBear

            FileMaker, Inc.

            • 3. Re: FMS11 IIS PHP Publish and automatic date diff calculation if field not null
              FlorianWiegand

              Dear PhilModJunks and TSBear,

              thank you very much for your quick and very exact answers.

              Case 1: I did manage to adapt the If statement to other fields in my database and it works perfectly!

              Case 2: I did manage to open the php file with a good editor and added the lines, i do sort of understand the code and can not find a reason why it does not work. The fields still show a red x if no set of data is available. I have made a screenshot and attached it. 

              One question, if we add this information and i republish a the page, will the changes be lost?

              Thank you very much for your exellent support

              • 4. Re: FMS11 IIS PHP Publish and automatic date diff calculation if field not null

                Florian Wiegand:

                My apologies, I should have been a bit more clear. Your code should look a bit more like this:

                <?php if(getImageURL(storeFieldNames('Attachments', 0, $record, true, 'EDITTEXT', 'container')) != "img.php?-url=") { ?>

                <td class="field_data">

                <img src="<?php echo getImageURL(storeFieldNames('Attachments', 0, $record, true, 'EDITTEXT', 'container'))?>">

                </td>

                <?php } ?>

                Specifically, we're removing the <>s from your field name in your first line. Other than that, everything looks perfect. 

                If you were to generate a new site using the PHP site assistant, any changes you made would be lost.

                TSBear

                FileMaker, Inc.

                • 5. Re: FMS11 IIS PHP Publish and automatic date diff calculation if field not null
                  FlorianWiegand

                  Dear TSBear,

                  thank you for describing the needed change for me. I have made the changes and it works beautifully. At first i noticed that it only worked in one view, but then i realized that i had to change the other php sites as well. Now my problems are solved and it works wonderfully. I am now going to design the home page manually based on the template the php publisher made for me. 

                  Thank you both for your support

                  Florian