Using FSDL to send data to the server
FSDL contains elements for sending three different kinds of data:
- File data, using the <setdata> and its child <data> elements – Data that is associated with a file that is read by Frogans Player;
- Session data, using the <session> element – Data taken from a previously-defined <setdata> element and that can remain valid as long as a user session is active;
- Entry data, using the <setentry> and its child <entry> elements – Data that is provided by the user through an entry form;
For the sake of simplicity, let’s concentrate on file data from here on out.
File data
Remember the <file> element? In FSDL, there has to be a <file> element for every file that is referred to in your FSDL code. For instance, if you want to use an image file, you must first reference it with a <file> element (before moving on to <resimage>,<layer> and so on). Similarly, you use a <file> element to reference the FSDL document of any slide to navigate (see Button Basics for more info).
There is an optional attribute in the <file> element, called “dataref,” whose value is that of the “dataid” found in a <setdata> element. In short, you
- define a piece of data in a <setdata> element,
- you attach it to a file in a <file> element and
- you open that file using a <button> element (or alternatively a <next> or <redirect> element).
Let’s look at examples for each step.
The <setdata> element
The <setdata> element lets you define data in “key-value” pairs. If I have a choice of three photos (“cat.jpg,” “dog.jpg,” “frog.jpg”), I might say that my key “photo” could have any one of three possible values.
I want to see photo of a cat, I’ll want the server to see a piece of data that says:
photo=cat.jpg
So, I’ll write a <setdata> element like:
<setdata dataid='cat_data'> <data key='photo'>cat.jpg</data> </setdata>
The <file> element
I want to set up a <file> element so that when its slide opens up, it’s going to know that “photo”=”cat.jpg”. To do this, I simply set the “nature” attribute to “dynamic” and include a “dataref” attribute whose value is the same as that of the “dataid” shown above:
<file fileid='photoslide_f' nature='dynamic' name='/photoslide.php' dataref='cat_data'/>
The <button> element
Finally, I use the “fileid”s value of for the “fileref” element in a button:
<button buttonid='btn_cat' goto='slide' fileref='photoslide_f' >...
To summarize the FSDL production chain in the above example:
key-value -> data -> file -> button photo=cat.jpg cat_data photoslide_f btn_cat
When the user clicks on the button, Frogans Player will request the file “photoslide.php” from the server while sending data that is “photo=cat.jpg”.
Leave a Reply