|
Lesson 1 - The Basics
Adding PHP code to Fusion pages -
Fusion allows you to add additional code to your web pages. In a text box or table cell you can do Ctrl+T and insert code into the box that appears. This example is a PHP function that displays the current
date.

When Fusion generates the code, it incorporates your added code into the resulting web page.
Inserting the code above after pressing Ctrl+T following the ':' at the end of this sentence causes the current date to be displayed here: May 17th, 2008
Note: this is just one format for displaying a date - PHP gives you many, many options here.
If you place this code in a table cell, you can use the cells text properties to control the color of the text the date appears in - whether it's centered, etc..
For example:
Note: Your page name must include the .php suffix for your web server to recognize that the page contains PHP code to be processed. Do this in Fusion Site View by selecting your page, pressing F3, then the Custom
Names button and then entering .php as your file extension as below. Note: Fusion 8.0 and above have dynamic page extensions built-in.
PHP code can be used to display information in several ways. As the results of a function (as in the inserting the current date onto a page example), a literal string or data fields retrieved
from a database. Your PHP code can also include HTML to generate entire tables with data inserted. ([tease] you can even an insert PHP code into an input field on a form)
Another way to add PHP code is in Fusion's HTML Source view. The ONLY time you should do this is when enabling PHP session control in Fusion MX or 7. In Fusion 7.5 and above, there's a
tab in Layout properties HTML and Master Border properties HTML where you can insert code.
Fusion allows absolute placement of design objects on your pages. When you use the technique above, the output begins where you have your cursor when you use Ctrl+T. When
you add PHP code, keep in mind the size of the generated output. It WILL affect other objects on your page in some instances. Make sure text boxes or cells have room to expand to accommodate the output from the script.
Try the exercise above. Soon we'll move on to some "real world problems" and their solutions using Fusion and PHP. But first....
Lesson 2 - Basic PHP and Fusion
|