Php webtags: Difference between revisions

3,611 bytes removed ,  10:51, 20 April 2020
m
Line 209: Line 209:
#Leave the '''Binary''' column unticked.
#Leave the '''Binary''' column unticked.
#If you have not ticked the realtime column, your file will be uploaded at the normal uploading interval unless you tick the '''End of Day''' column. If you do tick here, then your file will be uploaded right at the end of the rollover process, at this stage Cumulus will have the new date in every date type tag, it will have initialised the monthly tags to be empty, and the yesterday tags will have been set. In other words, you will only use this option if you have other web tag templates being uploaded during the day.
#If you have not ticked the realtime column, your file will be uploaded at the normal uploading interval unless you tick the '''End of Day''' column. If you do tick here, then your file will be uploaded right at the end of the rollover process, at this stage Cumulus will have the new date in every date type tag, it will have initialised the monthly tags to be empty, and the yesterday tags will have been set. In other words, you will only use this option if you have other web tag templates being uploaded during the day.
==Usage==
Use the PHP [http://www.w3schools.com/PHP/php_includes.asp include/require] command to include the Cumulus web tags into your PHP file.  Then where you would insert a web tag if you were writing a template, you insert a command to "echo" the php variable <pre><?=$PHP_variable_name[any_index_needed];?></pre>
The "=" in the above example is shorthand for " echo " with the spacing shown. In most of the ready made files listed for download on this page the PHP variable names are either identical to their [[webtags]] equivalent or have a name that reflects the output parameters selected, but of course if you are editing the file you might choose different names. For example in provided code, the Cumulus webtag <tt><#forecast></tt> would be referred to as <tt>$forecast</tt> in your PHP file.
However the beauty of using script (PHP or another) is that you can add other aspects of the script language like conditions and control what HTML is output. For instance if a PHP variable tells you it is not raining you might leave out displaying the current rain rate. Or if it is night time you might report fewer derivatives than if it is day time. If it is the first day of a month, then you can leave out the rows in your table that would report the highest and lowest for the month that are not yet defined. Such php script might look something like this example that wants alternating rows to look different and has to adapt that if one row is left out:
<pre>
<?php if ($show_apptemp){ ?>
              <tr class="even">
                  <td><span lang="en">Apparent Temperature</span></td>
                  <td style="text-align:right;"><span class="ajax" id="ajaxapptempNoU"><?php echo $RT_apptemp ?></span></td>
                  <td><?php echo $tempunit; ?></td>
              </tr>
              <tr class="odd">
                  <td><span lang="en">Heat Index</span></td>
                  <td style="text-align:right;"><span class="ajax" id="ajaxheatidxNoU"><?php echo $RT_heatindex ?></span></td>
                  <td><?php echo $tempunit; ?></td>
              </tr>
              <tr class="even">
                  <td><span lang="en">Humidex</span></td>
                  <td style="text-align:right;"><span class="ajax" id="ajaxhumidexNoU"><?php echo $RT_humidex ?></span></td>
                  <td><?php echo $tempunit; ?></td>
              </tr>
          <!--    <tr class="odd">
                  <td><span lang="en">Indoor Temperature</span></td>
                  <td style="text-align:right;"><span class="ajax" id="ajaxintempNoU"><?php echo $RT_intemp ?></span></td>
                  <td><?php echo $tempunit; ?></td>
              </tr> -->
<?php }else{ ?>
              <tr class="even">
                  <td><span lang="en">Heat Index</span></td>
                  <td style="text-align:right;"><span class="ajax" id="ajaxheatidxNoU"><?php echo $RT_heatindex ?></span></td>
                  <td><?php echo $tempunit; ?></td>
              </tr>
              <tr class="odd">
                  <td><span lang="en">Humidex</span></td>
                  <td style="text-align:right;"><span class="ajax" id="ajaxhumidexNoU"><?php echo $RT_humidex ?></span></td>
                  <td><?php echo $tempunit; ?></td>
              </tr>
              <tr class="even">
                  <td><span lang="en">Indoor Temperature</span></td>
                  <td style="text-align:right;"><span class="ajax" id="ajaxintempNoU"><?php echo $RT_intemp ?></span></td>
                  <td><?php echo $tempunit; ?></td>
              </tr>
<?php } ?>
</pre>


==Example==
==Example==
5,838

edits