Not logged in

API Documentation


API If you have a website, you can use this API to retrieve virtually any information from your event and put it in your webpage.
The API is available

It offers endless possibilities, from image repositories to content manageable pages.

The use of the API involves inserting a DIV in your html with a class 'castaform' and the 36 digit event key and an attribute 'data-query' which is an (MS)SQL query.
The content of the div should be empty, because it will be replaced by the result of the query.

Note that only fields can be retrieved which are explicitly set to be viewed publicly,
which you can do in the Form Editor > double click on an input control > On Result Page > Always show.
Also, formula fields cannot be retrieved this way at this moment.

For more info about SQL SELECT queries, click here

See an example here

 

 

 

See an example of a complete content manageable website made with just a few lines of code here

 

 

 

You can even use information from other events in a website like the one above
by adding castaform divs as (part of) the content, demonstrated here
Used like this, different (power) users can update different parts of the website.

Syntax <div class="castaform event_key" data-query="sql_qyery|print_pattern|lastrow_print_pattern|before-html|after_html"></div>

event_key: a 36 digit unique event_key of your event

sql_query: a valid (MS)SQL select query on the table 'castaform'
Example: select top 5 {name},{city} from castaform
Note: in CastaForm, field names have to be placed between curly brackets

print_pattern: if omitted or empty, the output will be as a table and the rest of the parmeters will be ignored; else placeholders {*} are replaced by result fields.
Example: {*} ({*})<br>

lastrow_print_pattern: Optional, print pattern for the last row. If ommitted or empty, then the same pattern as the rest will be used
Example: and last but not least {*} ({*})<br>

before_ and after_html: Optional HTML to be included before or after the result.
Example: select distinct {country} from castaform|<li>{*}</li>||<ul>|</ul>

SQL Examples all examples are on the example tables 'Hotels in Indochina' or 'CastaForm pics'
description query in action
Get a list of countries. Since we don't specify a print pattern, the output will be in table form select distinct {country} from castaform show
specifying a print pattern select count(*) from castaform|We have {*} hotels show
a table with more fields select {name} as Hotel,{address} as Address from castaform where {city}='chiang rai' order by {name} show
specifying a print pattern and wrap it in an ordered list: select distinct {country} from castaform|<li>{*}</li>||<ol>|</ol> show
specifying a print pattern and a pattern for the last row select distinct {country} from castaform|{*}, |and last but not least {*}.
show
specifying a print pattern for multiple fields select {country},count({name}) from castaform group by {country}|{*} ({*}), | and last but not least {*} ({*})
show
Retrieving an image select {image} from castaform where {caption}='ba be'|{*} click me!
show
Retrieving a random image select top 1 {image},{caption} from castaform order by newID()|{*}<br />{*} show
Retrieving multiple images select top 5 {image} from castaform|{*} show

Styling
When using a table as output, the following style classes are applied:

tagclass
<table>casta_table
<th>casta_th
<th>casta_th + column number
<th>casta_theven
<th>casta_thodd
<tr>casta_treven
<tr>casta_trodd
<td>casta_td + column number
<td>casta_tdeven
<td>casta_tdodd

All these style classes are empty, you have to write your own styles.
e.g.
<style type='text/css'>
   .casta_table {border:1px solid, #dddddd;}
</style>

JavaScript

 

castaform.init()

generates the div content based on the query for divs that have not been processed previously

castaform.setQuery(obj,event_c,query)

Changes a div to become a CastaForm query result

castaform.reQuery(obj)

execute the query again


castaform.finished(obj)

always called when a div is filled with the result of a query

this is an empty function, define your own when necessary e.g.

castform.finished = function(somediv) {
    div.style.display='inline-block'
}
   


Images
onclick
All images have an onclick event defined: castaform.showPic(imgObject,bigImageSrc) which is empty.
You can define your own function here e.g.

castaform.showPic=function(img,src) {
   alert(src)
   myImageviewer(src)
}

onload
Upon the onload event of an image, the function castaform.onPicLoad(imgObject,bigImageSrc) is called which is empty.
You can define your own function here e.g.

castaform.onPicLoad=function(img,src) {
   alert(src)
   doSomeStuff(img)
}