Terra Dotta Software API Documentation
Back to Terra Dotta Software API Documentation Return to Public Site
Top
Top
Using our original call:
(the following XML packet is formatted for readability)
We can modify the call to return the data in SOAP format by specifying
(the following XML packet is formatted for readability)
We can modify the call to return the data in JSON format by specifying
(the following JSON packet is formatted for readability)
Example 1: Following is an example using JSON and client-side JavaScript to render the program names as link and indicating whether or not the programs are incoming:
Run Example 1 Top
(if your installation does not have any data, this example may not return anything)
Run Example 2 Top
(if your installation does not have any data, this example will not return anything)
For additional techniques, be sure to visit the other program calls within these documentation pages.
Back to Terra Dotta Software API Documentation Top
getProgramSearchResults
Returns a list of search form elements to be used to create a custom program search page.URL
http://{site root}/piapi/index.cfm?callname=getProgramSearchResults&ResponseEncoding=json
The value for {site root} would represent your installation URL. The values returned from this function are in the following table.
- Table 1: Input arguments for getProgramSearchResults
- Table 2: Return values for getProgramSearchResults
- Example 1: Calling getProgramSearchResults with JavaScript
- Example 2: Calling getProgramSearchResults with ColdFusion
Top
Standard Input Parameters (jump to call specific input arguments) | |||
---|---|---|---|
Argument | Type | Required | Meaning |
ResponseEncoding | String | Optional |
The data format to be returned by the API call. The value for ResponseEncoding can be one of the following values:
(case insensitive) |
CallBack | Boolean | Optional | Used with JSON only to specify if a callback function will be used or not. |
CallBackName | String | Optional | Used with JSON only to specify the callback function to use. | Call-specific Input Parameters (jump to standard input arguments) |
Argument | Type | Required | Meaning |
ItemSort | String | Optional |
Sorts search results based on the value you specify.See the SortOrder field for values for specifying that results are returned in ascending or descending order.
(case insensitive) Default: Program_Name, Program_City, Program_Country, Program_Region
|
SortOrder | String | Optional |
Sorts search results in ascending or descending order, in conjunction with the value(s) you specify in ItemSort.The default is ascending order, or "asc".
(case insensitive) asc
|
City | String | Optional | Filters results based on city name. |
Country | String | Optional | Filters results based on country name. |
Region | String | Optional | Filters results based on region name. |
Term | String | Optional | Filters results based on term name. |
Params | String | Optional |
A serialized sorting of URL-encoded input program parameters (and their types) for use as a filter for which programs to return.
You would use this to filter in or out programs based on selected program parameter criteria for each program. Example: If you wanted to create a page that only returned a listing of programs that required a mimimum GPA of 3.0 with Language of Instruction of English or Spanish, your URL-encoded and serialized string might appear similar like the following:
p_10009=English%7F%2CSpanish%7F|p_10009_t=MULTI|p_10010=3%2E0%7F|p_10010_t=SELCT
This can be broken down into four pipe-delimited values, each of which is URL-encoded:
p_10009=English%7F%2CSpanish%7F
The first line, p_10009_t=MULTI p_10010=3%2E0%7F p_10010_t=SELCT p_10009=English%7F%2CSpanish%7F , is a comma-delimited list of 2 languages, English and Spanish.
The delimiter in this case is %2C (a comma, in URL-encoded format). The %7F is a value terminator, which allows the delimited values to contain commas themselves.
The value terminator should be placed after each search term, and before the delimiter (%2C).
The values 10009 and 10010 are the parameter IDs, which can be obtained from the getProgramParameters() API call.
The second line p_10009_t=MULTI contains the parameter type. Possible types include: MULTI (multi-select), SELCT (single-select), YESNO (Yes or No), MINIM (Minimum Value), MAXIM (Maximum Value), DATLK (Data table lookup), and DATAX (Data table lookup with search). So the final serialized string would follow this format:
p_ID#1=VALUE 1-1{ENCODED TERMINATOR}{ENCODED COMMA}VALUE 1-n{ENCODED TERMINATOR}{ENCODED COMMA}|p_ID#1_t=PARAM TYPE 1|
p_ID#2=VALUE 2-1{ENCODED TERMINATOR}{ENCODED COMMA}VALUE 2-n{ENCODED TERMINATOR}{ENCODED COMMA}|p_ID#2_t=PARAM TYPE 2| p_ID#n=VALUE n-1{ENCODED TERMINATOR}{ENCODED COMMA}VALUE n-n{ENCODED TERMINATOR}{ENCODED COMMA}|p_ID#n_t=PARAM TYPE n |
ProgramName | String | Optional | Keyword search for the program name. Keywords are separated by a comma (,), a semi-colon (;) or a space ( ). To return an exact phrase, the keywords may be within single or double quotes. |
ProgramType | Integer | Optional |
A filter for specifying the type(s) of programs to return. The default will return Outgoing with SideTrips and OneStep (1 ).
Default: Outgoing with SideTrips and OneStep
|
Sponsored | Integer | Optional |
A filter for specifying whether or not the programs are StudioAbroad Directory sponsored.
|
StartRow | Integer | Optional | Starting row of the program list. |
EndRow | Integer | Optional | Ending row of the program list. |
Top
Return Value | Type | Meaning |
---|---|---|
RecordCount | Integer | The number of programs returned matching the search criteria. |
RowCount | Integer | The number of program records in the programs object - this does not include the program records in the nested featured object. |
SearchVerbiage | String | The verbose output of what was search for. |
program_id | Integer | The numeric program identifier. |
program_name | String | The name of the program. |
program_city | String | The name of the program city. |
program_country | String | The name of the program country. |
program_region | String | The name of the program region. |
program_type_id | String |
A single-character value representing the type of program.
|
program_latitude | String | The latitudinal value of the program location. |
program_longitude | String | The longitudinal value of the program location. |
bexchangeavailable | Boolean | Indicates whether or not an exchange option is available for this program. 1 = Yes, 0 = No. |
benableprogramsave | Boolean | Indicates whether or not a program can be saved to an applicant profile. 1 = Yes, 0 = No. |
partners | Object |
An object containing partner institutions for the program. This return value is only available when ProgramType has this option enabled. The complex object will resemble the following:
<partners>
<partner> <program_partner>Partner Institution 1</program_partner> </partner> <partner> <program_partner>Partner Institution 2</program_partner> </partner> </partners> |
program_featured | Boolean | Indicates whether or not the program is a featured program. 1 = Yes, 0 = No. If yes, the program will also appear in the featured object (see next). |
featured | Object | An object containing featured programs matching the search criteria. This object will return all previous values (above) with the addition of terms and program_description (see next). |
FeaturedRecordCount | Integer | The number of featured programs returned matching the search criteria. |
terms | Object |
An object containing term information for the featured program. This return value is only available when featured programs match the search criteria. The complex object will resemble the following:
<terms>
<term> <program_term>Fall</program_term> </term> <term> <program_term>Spring</program_term> </term> </terms> |
program_desciption | String | This returns the first 250 characters of the program brochure, after HTML has been stripped. A bracketed ellipsis will appear if the content is determined to be longer than 250 characters, appearing as [...]. |
Using our original call:
http://{site root}/piapi/index.cfm?callName=getProgramSearchResults
We would receive a packet of data in XML format (the default), that might resemble the following:
(the following XML packet is formatted for readability)
<programs>
<recordcount>2</recordcount>
<program>
<program_id>10274</program_id>
<program_name>
AIFS in Hyderabad, Academic Year and Semester Programs
</program_name>
<program_city>Hyderabad</program_city>
<program_country>India</program_country>
<program_region>Asia</program_region>
<program_type_id>1</program_type_id>
<program_latitude>17.37528</program_latitude>
<program_longitude>78.47444</program_longitude>
<program_featured>0</program_featured>
<bexchangeavailable>0</bexchangeavailable>
<benableprogramsave/>
</program>
<program>
<program_id>10291</program_id>
<program_name>Arcadia University India - Study in India</program_name>
<program_city>Pune</program_city>
<program_country>India</program_country>
<program_region>Asia</program_region>
<program_type_id>1</program_type_id>
<program_latitude>18.51957</program_latitude>
<program_longitude>73.85535</program_longitude>
<program_featured>0</program_featured>
<bexchangeavailable>1</bexchangeavailable>
<benableprogramsave>1</benableprogramsave>
</program>
<featured>
<featuredrecordcount>1</featuredrecordcount>
<program>
<program_id>10326</program_id>
<program_name>Semester at Sea</program_name>
<program_city>Chennai</program_city>
<program_country>India</program_country>
<program_region>Asia</program_region>
<program_type_id>1</program_type_id>
<program_latitude>13.08784</program_latitude>
<program_longitude>80.27847</program_longitude>
<program_featured>1</program_featured>
<bexchangeavailable>0</bexchangeavailable>
<benableprogramsave/>
<program_description>
Semester at SeaTerm: Fall, Spring, Summer Description: Semester at Sea gives you a taste of the entire globe as you travel more than 24,000 nautical miles to as many as 13 off-the-beaten-path international destinations ... or to a single fascinating
[...]
</program_description>
<terms>
<term>
<program_term>Fall</program_term>
</term>
<term>
<program_term>Spring</program_term>
</term>
<term>
<program_term>Summer</program_term>
</term>
</terms>
<partners>
<partner>
<program_partner>University of Paris</program_partner>
</partner>
</partners>
</program>
</featured>
</programs>
<recordcount>2</recordcount>
<program>
<program_id>10274</program_id>
<program_name>
AIFS in Hyderabad, Academic Year and Semester Programs
</program_name>
<program_city>Hyderabad</program_city>
<program_country>India</program_country>
<program_region>Asia</program_region>
<program_type_id>1</program_type_id>
<program_latitude>17.37528</program_latitude>
<program_longitude>78.47444</program_longitude>
<program_featured>0</program_featured>
<bexchangeavailable>0</bexchangeavailable>
<benableprogramsave/>
</program>
<program>
<program_id>10291</program_id>
<program_name>Arcadia University India - Study in India</program_name>
<program_city>Pune</program_city>
<program_country>India</program_country>
<program_region>Asia</program_region>
<program_type_id>1</program_type_id>
<program_latitude>18.51957</program_latitude>
<program_longitude>73.85535</program_longitude>
<program_featured>0</program_featured>
<bexchangeavailable>1</bexchangeavailable>
<benableprogramsave>1</benableprogramsave>
</program>
<featured>
<featuredrecordcount>1</featuredrecordcount>
<program>
<program_id>10326</program_id>
<program_name>Semester at Sea</program_name>
<program_city>Chennai</program_city>
<program_country>India</program_country>
<program_region>Asia</program_region>
<program_type_id>1</program_type_id>
<program_latitude>13.08784</program_latitude>
<program_longitude>80.27847</program_longitude>
<program_featured>1</program_featured>
<bexchangeavailable>0</bexchangeavailable>
<benableprogramsave/>
<program_description>
Semester at SeaTerm: Fall, Spring, Summer Description: Semester at Sea gives you a taste of the entire globe as you travel more than 24,000 nautical miles to as many as 13 off-the-beaten-path international destinations ... or to a single fascinating
[...]
</program_description>
<terms>
<term>
<program_term>Fall</program_term>
</term>
<term>
<program_term>Spring</program_term>
</term>
<term>
<program_term>Summer</program_term>
</term>
</terms>
<partners>
<partner>
<program_partner>University of Paris</program_partner>
</partner>
</partners>
</program>
</featured>
</programs>
We can modify the call to return the data in SOAP format by specifying
ResponseEncoding=SOAP
:
http://{site root}/piapi/index.cfm?callName=getProgramSearchResults&ResponseEncoding=SOAP
We would receive a packet of XML wrapped within a SOAP envelope that might resemble the following:
(the following XML packet is formatted for readability)
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<programs>
<recordcount>2</recordcount>
<program>
<program_id>10274</program_id>
<program_name>
AIFS in Hyderabad, Academic Year and Semester Programs
</program_name>
<program_city>Hyderabad</program_city>
<program_country>India</program_country>
<program_region>Asia</program_region>
<program_type_id>1</program_type_id>
<program_latitude>17.37528</program_latitude>
<program_longitude>78.47444</program_longitude>
<program_featured>0</program_featured>
<bexchangeavailable>0</bexchangeavailable>
<benableprogramsave/>
</program>
<program>
<program_id>10291</program_id>
<program_name>Arcadia University India - Study in India</program_name>
<program_city>Pune</program_city>
<program_country>India</program_country>
<program_region>Asia</program_region>
<program_type_id>1</program_type_id>
<program_latitude>18.51957</program_latitude>
<program_longitude>73.85535</program_longitude>
<program_featured>0</program_featured>
<bexchangeavailable>1</bexchangeavailable>
<benableprogramsave>1</benableprogramsave>
</program>
<featured>
<featuredrecordcount>1</featuredrecordcount>
<program>
<program_id>10326</program_id>
<program_name>Semester at Sea</program_name>
<program_city>Chennai</program_city>
<program_country>India</program_country>
<program_region>Asia</program_region>
<program_type_id>1</program_type_id>
<program_latitude>13.08784</program_latitude>
<program_longitude>80.27847</program_longitude>
<program_featured>1</program_featured>
<bexchangeavailable>0</bexchangeavailable>
<benableprogramsave/>
<program_description>
Semester at SeaTerm: Fall, Spring, Summer Description: Semester at Sea gives you a taste of the entire globe as you travel more than 24,000 nautical miles to as many as 13 off-the-beaten-path international destinations ... or to a single fascinating
[...]
</program_description>
<terms>
<term>
<program_term>Fall</program_term>
</term>
<term>
<program_term>Spring</program_term>
</term>
<term>
<program_term>Summer</program_term>
</term>
</terms>
<partners>
<partner>
<program_partner>University of Paris</program_partner>
</partner>
</partners>
</program>
</featured>
</programs>
</soapenv:Body>
</soapenv:Envelope>
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<programs>
<recordcount>2</recordcount>
<program>
<program_id>10274</program_id>
<program_name>
AIFS in Hyderabad, Academic Year and Semester Programs
</program_name>
<program_city>Hyderabad</program_city>
<program_country>India</program_country>
<program_region>Asia</program_region>
<program_type_id>1</program_type_id>
<program_latitude>17.37528</program_latitude>
<program_longitude>78.47444</program_longitude>
<program_featured>0</program_featured>
<bexchangeavailable>0</bexchangeavailable>
<benableprogramsave/>
</program>
<program>
<program_id>10291</program_id>
<program_name>Arcadia University India - Study in India</program_name>
<program_city>Pune</program_city>
<program_country>India</program_country>
<program_region>Asia</program_region>
<program_type_id>1</program_type_id>
<program_latitude>18.51957</program_latitude>
<program_longitude>73.85535</program_longitude>
<program_featured>0</program_featured>
<bexchangeavailable>1</bexchangeavailable>
<benableprogramsave>1</benableprogramsave>
</program>
<featured>
<featuredrecordcount>1</featuredrecordcount>
<program>
<program_id>10326</program_id>
<program_name>Semester at Sea</program_name>
<program_city>Chennai</program_city>
<program_country>India</program_country>
<program_region>Asia</program_region>
<program_type_id>1</program_type_id>
<program_latitude>13.08784</program_latitude>
<program_longitude>80.27847</program_longitude>
<program_featured>1</program_featured>
<bexchangeavailable>0</bexchangeavailable>
<benableprogramsave/>
<program_description>
Semester at SeaTerm: Fall, Spring, Summer Description: Semester at Sea gives you a taste of the entire globe as you travel more than 24,000 nautical miles to as many as 13 off-the-beaten-path international destinations ... or to a single fascinating
[...]
</program_description>
<terms>
<term>
<program_term>Fall</program_term>
</term>
<term>
<program_term>Spring</program_term>
</term>
<term>
<program_term>Summer</program_term>
</term>
</terms>
<partners>
<partner>
<program_partner>University of Paris</program_partner>
</partner>
</partners>
</program>
</featured>
</programs>
</soapenv:Body>
</soapenv:Envelope>
We can modify the call to return the data in JSON format by specifying
ResponseEncoding=JSON
:
http://{site root}/piapi/index.cfm?callName=getProgramSearchResults&ResponseEncoding=JSON
We would receive a JSON-encoded packet:
(the following JSON packet is formatted for readability)
_cb_getProgramSearchResults({
"PROGRAM":{
"2":{
"PROGRAM_LONGITUDE":73.85535,
"PROGRAM_REGION":"Asia",
"PROGRAM_LATITUDE":18.51957,
"PROGRAM_CITY":"Pune",
"PROGRAM_ID":10291,
"PROGRAM_COUNTRY":"India",
"BENABLEPROGRAMSAVE":1,
"BEXCHANGEAVAILABLE":1,
"PROGRAM_TYPE_ID":"1",
"PROGRAM_FEATURED":0,
"PROGRAM_NAME":"Arcadia University India - Study in India"
},
"1":{
"PROGRAM_LONGITUDE":78.47444,
"PROGRAM_REGION":"Asia",
"PROGRAM_LATITUDE":17.37528,
"PROGRAM_CITY":"Hyderabad",
"PROGRAM_ID":10274,
"PROGRAM_COUNTRY":"India",
"BENABLEPROGRAMSAVE":"",
"BEXCHANGEAVAILABLE":0,
"PROGRAM_TYPE_ID":"1",
"PROGRAM_FEATURED":0,
"PROGRAM_NAME":"AIFS in Hyderabad, Academic Year and Semester Programs"
}
},
"RECORDCOUNT":2,
"FEATURED":{
"PROGRAM":{
"PROGRAM_LONGITUDE":80.27847,
"PROGRAM_CITY":"Chennai",
"PARTNERS":{
"PARTNER":{
"PROGRAM_PARTNER":"University of Paris"
}
},
"PROGRAM_ID":10326,
"TERMS":{
"TERM":{
"3":{
"PROGRAM_TERM":"Summer"
},
"2":{
"PROGRAM_TERM":"Spring"
},
"1":{
"PROGRAM_TERM":"Fall"
}
}
},
"PROGRAM_DESCRIPTION":"Semester at SeaTerm: Fall, Spring, Summer Description: Semester at Sea gives you a taste of the entire globe as you travel more than 24,000 nautical miles to as many as 13 off-the-beaten-path international destinations ... or to a single fascinating\n\t\t [...]",
"BEXCHANGEAVAILABLE":0,
"PROGRAM_TYPE_ID":"1",
"PROGRAM_REGION":"Asia",
"PROGRAM_LATITUDE":13.08784,
"PROGRAM_COUNTRY":"India",
"BENABLEPROGRAMSAVE":"",
"PROGRAM_NAME":"Semester at Sea",
"PROGRAM_FEATURED":1
},
"FEATUREDRECORDCOUNT":1
}
});
The data returned using JSON encoding is wrapped within the callback function, "PROGRAM":{
"2":{
"PROGRAM_LONGITUDE":73.85535,
"PROGRAM_REGION":"Asia",
"PROGRAM_LATITUDE":18.51957,
"PROGRAM_CITY":"Pune",
"PROGRAM_ID":10291,
"PROGRAM_COUNTRY":"India",
"BENABLEPROGRAMSAVE":1,
"BEXCHANGEAVAILABLE":1,
"PROGRAM_TYPE_ID":"1",
"PROGRAM_FEATURED":0,
"PROGRAM_NAME":"Arcadia University India - Study in India"
},
"1":{
"PROGRAM_LONGITUDE":78.47444,
"PROGRAM_REGION":"Asia",
"PROGRAM_LATITUDE":17.37528,
"PROGRAM_CITY":"Hyderabad",
"PROGRAM_ID":10274,
"PROGRAM_COUNTRY":"India",
"BENABLEPROGRAMSAVE":"",
"BEXCHANGEAVAILABLE":0,
"PROGRAM_TYPE_ID":"1",
"PROGRAM_FEATURED":0,
"PROGRAM_NAME":"AIFS in Hyderabad, Academic Year and Semester Programs"
}
},
"RECORDCOUNT":2,
"FEATURED":{
"PROGRAM":{
"PROGRAM_LONGITUDE":80.27847,
"PROGRAM_CITY":"Chennai",
"PARTNERS":{
"PARTNER":{
"PROGRAM_PARTNER":"University of Paris"
}
},
"PROGRAM_ID":10326,
"TERMS":{
"TERM":{
"3":{
"PROGRAM_TERM":"Summer"
},
"2":{
"PROGRAM_TERM":"Spring"
},
"1":{
"PROGRAM_TERM":"Fall"
}
}
},
"PROGRAM_DESCRIPTION":"Semester at SeaTerm: Fall, Spring, Summer Description: Semester at Sea gives you a taste of the entire globe as you travel more than 24,000 nautical miles to as many as 13 off-the-beaten-path international destinations ... or to a single fascinating\n\t\t [...]",
"BEXCHANGEAVAILABLE":0,
"PROGRAM_TYPE_ID":"1",
"PROGRAM_REGION":"Asia",
"PROGRAM_LATITUDE":13.08784,
"PROGRAM_COUNTRY":"India",
"BENABLEPROGRAMSAVE":"",
"PROGRAM_NAME":"Semester at Sea",
"PROGRAM_FEATURED":1
},
"FEATUREDRECORDCOUNT":1
}
});
_cb_getProgramSearchResults&ResponseEncoding()
.
By default, all JSON calls are returned within a callback wrapper function in form of:
_cb_callName()
Where callName
represents the name of the function you originally called.
To override this, you can specify the callBackName
argument, as in:
http://{site root}/piapi/index.cfm?callName=getProgramSearchResults&ResponseEncoding=JSON&callBackName=MyCallBackFunction
This call would return the JSON packet wrapped within the callback function, MyCallBackFunction
, as in:
_cb_MyCallBackFunction(...json-encoded data...)
In your custom pages, you would then create a corresponding function to handle this custom callback function:
<script language="JavaScript" type="text/javascript">
<!--
// <![CDATA[
function _cb_MyCallBackFunction(data)
{
// put additional routines here
}
// ]]>
//-->
</script>
If you would like to receive the data without a callback function, you can use the argument <!--
// <![CDATA[
function _cb_MyCallBackFunction(data)
{
// put additional routines here
}
// ]]>
//-->
</script>
callBack
to override this. Specifying a value of false
for the callBack
argument returns the data without the callback function, as in:
http://{site root}/piapi/index.cfm?callName=getProgramSearchResults&ResponseEncoding=JSON&callBack=false
Note: specifying callBack=true
is implied and is unnecessary for returning JSON data with a callback function.
Example 1: Following is an example using JSON and client-side JavaScript to render the program names as link and indicating whether or not the programs are incoming:
Run Example 1 Top
(if your installation does not have any data, this example may not return anything)
<script language="javascript" type="text/javascript">
var pagelimit = 10;
var pagenumber = 1;
var numberofpages = '';
var orderby = 'asc';
var fieldname = '';
var searchresultpagecontent = '<div id="programlistcontainer"><div id="container"><div id="main-content"><div class="one-col-row"><div class="c1"><div class="program-block"><div class="list-block"><!--FEATUREDPROGRAM LIST ROWSTART--><div class="featured-programs"><div class="overview"><div class="left"><a href="javascript:void(0)" onclick="getProgrambrochure({FEATUREDPROGRAM_ID})"><!--{FEATUREDPROGRAM_NAME}--></a><br /> <!--{FEATUREDPROGRAM_CITY}-->, <!--{FEATUREDPROGRAM_COUNTRY}--></div><div class="right"><span>Terms:</span> <!--{FEATUREDPROGRAM_TERM}--><br /><span>Partner(s):</span> <!--{FEATUREDPROGRAM_PARTNER}--></div></div><div class="description"><span>Description:</span> <!--{FEATUREDPROGRAM_DESCRIPTION}--></div></div><!--FEATUREDPROGRAM LIST ROWEND--><!--</div>--><div class="list-info">Currently, the listing is showing Outgoing Programs, sorted by <span>Name</span>.</div><!--<div class="list-buttons"><ul><li class="selected"><a href="#">Outgoing</a></li><li><a href="#">Scholarships</a></li></ul></div>--><div class="legend">(F) Featured Programs (Inactive) Program Not Active</div><div class="list-all"><table width="903" border="0" cellspacing="0" cellpadding="2"><thead class="table-head"><tr><th align="left" class="first">Program Name <a href="javascript:void(0)" onclick="sortbyPrgName()">SortByName</a></th><th align="left" valign="middle">City <a href="javascript:void(0)" onclick="sortbyPrgCity()">SortByCity</a></th><th align="left">Country <a href="javascript:void(0)" onclick="sortbyPrgCountry()">SortByCountry</a></th><th align="left">Region <a href="javascript:void(0)" onclick="sortbyPrgRegion()">SortByRegion</a></th></tr></thead><!--PROGRAM LIST ROWSTART--><tr><td align="left" class="{CLASS_NAME}"><a href="javascript:void(0)" onclick="getProgrambrochure({PROGRAM_ID})" title="<!--{PROGRAM_NAME}-->"><!--{PROGRAM_NAME}--></a> <!--{BIT_FEATURED}--></td><td align="left" class="{CLASS_NAME}"><!--{PROGRAM_CITY}--></td><td align="left" class="{CLASS_NAME}"><!--{PROGRAM_COUNTRY}--></td><td align="left" class="{CLASS_NAME}"><!--{PROGRAM_REGION}--></td></tr><!--PROGRAM LIST ROWEND--></table><div class="list-paging" align="center"><span><a href="javascript:void(0)" onclick="gotoprevpage()">«</a></span><!--PAGES START--><span id="pagingclass" class="{PAGING_CLASS_NAME}"><a id="pages" onclick="gotopage(this.innerHTML)" href="javascript:void(0)"><!--{PAGES}--></a></span><!--PAGES END--><span><a href="javascript:void(0)" onclick="gotonextpage()">»</a></span></div></div></div><!--</div>--><!--</div>--><!--</div>--></div></div></div></div><div id="footer" align="center"> By Terra Dotta. Technology for educating the world. Copyright Terra Dotta, LLC. All Rights Reserved. </div></div></div>';
<!--Domain name, API url and site url-->
<!--Base url can be modified corresponding to the University/School-->
var domainname = '<cfoutput>#REQUEST.CurrentAccount.AuthHostDomain()#</cfoutput>';
var baseapiurl = '<cfoutput>#REQUEST.CurrentAccount.AuthHostProtocol()#://</cfoutput>'+domainname+'<cfoutput>#REQUEST.CurrentAccount.AuthHostPort()##REQUEST.CurrentAccount.AuthHostRelativeRoot()#</cfoutput>piapi/index.cfm';
var basesiteurl = '<cfoutput>#REQUEST.CurrentAccount.AuthHostProtocol()#://</cfoutput>'+domainname+'<cfoutput>#REQUEST.CurrentAccount.AuthHostPort()##REQUEST.CurrentAccount.AuthHostRelativeRoot()#</cfoutput>index.cfm';
var programlist ='';
<!--Function used to get url values-->
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
<!--Function used to call program search results API-->
function callApi(pnumber) {
pagenumber = pnumber;
var startrow = (pnumber - 1) * pagelimit;
var endrow = startrow + pagelimit;
<!--Variable contains the program search result content block-->
programlist = searchresultpagecontent;
var url = baseapiurl + '?callname=getProgramSearchResults&ResponseEncoding=json';
var hash = getUrlVars();
var city = '';
var country = '';
var region = '';
var term = '';
if (hash['city']) city = hash['city'];
if (hash['country']) country = hash['country'];
if (hash['region']) region = hash['region'];
if (hash['term']) term = hash['term'];
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url + '&city=' + city + '&country=' + country + '®ion=' + region + '&term=' + term + '&startrow=' + startrow + '&endrow=' + endrow;
if (fieldname != '') {
script.src = url + '&city=' + city + '&country=' + country + '®ion=' + region + '&term=' + term + '&startrow=' + startrow + '&endrow=' + endrow + '&itemSort=' + fieldname + '&sortOrder=' + orderby;
}
head.appendChild(script);
}
function _cb_getProgramSearchResults(root) {
<!--Variables rwString and frwString used to get specific content block-->
rwString = programlist.substring(programlist.indexOf('<!--PROGRAM LIST ROWSTART-->') + 28, programlist.indexOf('<!--PROGRAM LIST ROWEND-->'));
frwString = programlist.substring(programlist.indexOf('<!--FEATUREDPROGRAM LIST ROWSTART-->') + 36, programlist.indexOf('<!--FEATUREDPROGRAM LIST ROWEND-->'));
previousnextString = programlist.substring(programlist.indexOf('<!--PREVIOUS START-->') + 22, programlist.indexOf('<!--PREVIOUS END-->'));
pagingString = programlist.substring(programlist.indexOf('<!--PAGES START-->') + 18, programlist.indexOf('<!--PAGES END-->'));
<!--Variable used to store featured image-->
featuredimage = '(F)';
<!--Below variables used to get program details-->
var progname = '';
var progcity = '';
var progcountry = '';
var progregion = '';
var progid = 0;
var programfeatured = 0;
<!--Variable to append all programs list-->
var appendlist = '';
<!--Variable to append all featured programs-->
var appendfeatured = '';
<!--Variable to append all page numbers-->
var appendpaging = '';
if (root.RECORDCOUNT > 0) {
<!--To get all programs list-->
var rs = root.PROGRAM;
if (rs) {
for (var key in rs) {
var obj = rs[key];
progname = '';
progcity = '';
progcountry = '';
progregion = '';
for (var prop in obj) {
if (prop == 'PROGRAM_NAME') progname = obj[prop];
if (prop == 'PROGRAM_CITY') progcity = obj[prop];
if (prop == 'PROGRAM_COUNTRY') progcountry = obj[prop];
if (prop == 'PROGRAM_REGION') progregion = obj[prop];
if (prop == 'PROGRAM_ID') progid = obj[prop];
if (prop == 'PROGRAM_FEATURED') programfeatured = obj[prop];
}
<!--Replace the custom keywords used in the html content with corresponding values-->
rplcedRow = rwString.replace(/<!--{PROGRAM_NAME}-->/g, progname);
rplcedRow = rplcedRow.replace('<!--{PROGRAM_CITY}-->', progcity);
rplcedRow = rplcedRow.replace('<!--{PROGRAM_COUNTRY}-->', progcountry);
rplcedRow = rplcedRow.replace('<!--{PROGRAM_REGION}-->', progregion);
rplcedRow = rplcedRow.replace('{PROGRAM_ID}', progid);
if (programfeatured == 1) rplcedRow = rplcedRow.replace('<!--{BIT_FEATURED}-->', featuredimage);
else rplcedRow = rplcedRow.replace('<!--{BIT_FEATURED}-->', '');
if (key % 2 == 0) rplcedRow = rplcedRow.replace(/{CLASS_NAME}/g, 'listing-cell');
else rplcedRow = rplcedRow.replace(/{CLASS_NAME}/g, 'listing-cell alternate-row');
appendlist = appendlist + rplcedRow;
}
}
if (root.FEATURED) {
<!--To get all featured programs-->
if (root.FEATURED.FEATUREDRECORDCOUNT > 0) {
<!--Below variables used to get featured program details-->
var featuredprogid = 0;
var featuredprogname = '';
var featuredprogcity = '';
var featuredprogcountry = '';
var featuredprogdesc = '';
var featuredprogterm = '';
var featuredprogpartner = '';
var featuredprogexchange = '';
var progterm = '';
var progpartner = '';
var singleprogterm = '';
var singleprogpartner = '';
var prevprgid = '';
var rs_featured = root.FEATURED.PROGRAM;
if (root.FEATURED.FEATUREDRECORDCOUNT > 1) {
if (rs_featured) {
for (var key in rs_featured) {
if (!rs_featured[key].length) {
var obj = rs_featured[key];
for (var prop in obj) {
if (prop == 'PROGRAM_ID') {
featuredprogid = obj[prop];
}
if (!obj[prop].length) {
if (prop && typeof obj[prop] == 'object') {
var obj1 = obj[prop];
for (var prop1 in obj1) {
var obj2 = obj1[prop1];
for (var prop2 in obj2) {
var obj3 = obj2[prop2];
if (obj2[prop2].length) {
if (prop2 == 'PROGRAM_TERM') {
singleprogterm = obj2[prop2];
featuredprogterm = singleprogterm;
}
if (prop2 == 'PROGRAM_PARTNER') {
singleprogpartner = obj2[prop2];
featuredprogpartner = singleprogpartner;
}
} else {
var progterm = '';
var progpartner = '';
for (var prop3 in obj3) {
if (prop3 == 'PROGRAM_TERM') {
progterm = obj3[prop3];
}
if (prop3 == 'PROGRAM_PARTNER') {
progpartner = obj3[prop3];
}
}
if (featuredprogterm != '') featuredprogterm = featuredprogterm + ',' + progterm;
else featuredprogterm = progterm;
if (featuredprogpartner != '') featuredprogpartner = featuredprogpartner + ',' + progpartner;
else featuredprogpartner = progpartner;
}
}
}
}
} else {
if (prop == 'PROGRAM_NAME') featuredprogname = obj[prop];
if (prop == 'PROGRAM_CITY') featuredprogcity = obj[prop];
if (prop == 'PROGRAM_COUNTRY') featuredprogcountry = obj[prop];
if (prop == 'BEXCHANGEAVAILABLE') featuredprogexchange = obj[prop];
if (prop == 'PROGRAM_DESCRIPTION') featuredprogdesc = obj[prop];
}
}
}
<!--Replace the custom keywords used in the html content with corresponding values-->
frplcedRow = frwString.replace('<!--{FEATUREDPROGRAM_NAME}-->', featuredprogname);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_CITY}-->', featuredprogcity);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_COUNTRY}-->', featuredprogcountry);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_TERM}-->', featuredprogterm);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_PARTNER}-->', featuredprogpartner);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_DESCRIPTION}-->', featuredprogdesc);
frplcedRow = frplcedRow.replace('{FEATUREDPROGRAM_ID}', featuredprogid);
appendfeatured = appendfeatured + frplcedRow;
featuredprogterm = '';
featuredprogpartner = '';
}
}
} else {
if (rs_featured) {
for (var key in rs_featured) {
if (key == 'PROGRAM_ID') featuredprogid = rs_featured[key];
if (!rs_featured[key].length) {
var obj = rs_featured[key];
for (var prop in obj) {
if (prop && typeof obj[prop] == 'object') {
var obj1 = obj[prop];
for (var prop1 in obj1) {
var obj2 = obj1[prop1];
for (var prop2 in obj2) {
if (prop2 == 'PROGRAM_TERM') {
progterm = obj2[prop2];
}
if (prop2 == 'PROGRAM_PARTNER') {
progpartner = obj2[prop2];
}
}
if (featuredprogterm != '') featuredprogterm = featuredprogterm + ',' + progterm;
else featuredprogterm = progterm;
if (featuredprogpartner != '') featuredprogpartner = featuredprogpartner + ',' + progpartner;
else featuredprogpartner = progpartner;
}
}
}
} else {
if (key == 'PROGRAM_NAME') featuredprogname = rs_featured[key];
if (key == 'PROGRAM_CITY') featuredprogcity = rs_featured[key];
if (key == 'PROGRAM_COUNTRY') featuredprogcountry = rs_featured[key];
if (key == 'BEXCHANGEAVAILABLE') featuredprogexchange = rs_featured[key];
if (key == 'PROGRAM_DESCRIPTION') featuredprogdesc = rs_featured[key];
}
}
<!--Replace the custom keywords used in the html content with corresponding values-->
frplcedRow = frwString.replace('<!--{FEATUREDPROGRAM_NAME}-->', featuredprogname);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_CITY}-->', featuredprogcity);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_COUNTRY}-->', featuredprogcountry);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_TERM}-->', featuredprogterm);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_PARTNER}-->', featuredprogpartner);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_DESCRIPTION}-->', featuredprogdesc);
frplcedRow = frplcedRow.replace('{FEATUREDPROGRAM_ID}', featuredprogid);
appendfeatured = appendfeatured + frplcedRow;
}
}
}
}
<!--Variable to get total number of records-->
var totalrecords = root.RECORDCOUNT;
<!--Variable to get total number of pages-->
numberofpages = Math.round(totalrecords / pagelimit);
for (i = 1; i <= numberofpages; i++) {
rplcedPageNumber = pagingString.replace('<!--{PAGES}-->', i);
if (pagenumber == i) rplcedPageNumber = rplcedPageNumber.replace('{PAGING_CLASS_NAME}', 'selected');
else rplcedPageNumber = rplcedPageNumber.replace('{PAGING_CLASS_NAME}', '');
appendpaging = appendpaging + rplcedPageNumber;
}
}
<!--Variables tobereplaced , ftobereplaced and pagingStringtobereplaced used to replace specific content block with corresponding values-->
tobereplaced = programlist.substring(programlist.indexOf('<!--PROGRAM LIST ROWSTART-->'), programlist.indexOf('<!--PROGRAM LIST ROWEND-->') + 26);
ftobereplaced = programlist.substring(programlist.indexOf('<!--FEATUREDPROGRAM LIST ROWSTART-->'), programlist.indexOf('<!--FEATUREDPROGRAM LIST ROWEND-->') + 34);
pagingStringtobereplaced = programlist.substring(programlist.indexOf('<!--PAGES START-->'), programlist.indexOf('<!--PAGES END-->') + 16);
programlist = programlist.replace(tobereplaced, appendlist);
programlist = programlist.replace(ftobereplaced, appendfeatured);
programlist = programlist.replace(pagingStringtobereplaced, appendpaging);
document.getElementById('results').innerHTML = programlist;
}
<!--Function used to get the selected page-->
function gotopage(pnum) {
callApi(pnum);
}
<!--Function used to get the next page-->
function gotonextpage() {
if (pagenumber != numberofpages) pagenumber = pagenumber + 1;
else pagenumber = pagenumber;
callApi(pagenumber);
}
<!--Function used to get the previous page-->
function gotoprevpage() {
if (pagenumber != 1) pagenumber = pagenumber - 1;
else pagenumber = pagenumber;
callApi(pagenumber);
}
<!--Function used to sort programs by program name-->
function sortbyPrgName() {
fieldname = 'Program_Name';
if (orderby == 'asc') orderby = 'desc';
else orderby = 'asc';
callApi(pagenumber);
}
<!--Function used to sort programs by program city-->
function sortbyPrgCity() {
fieldname = 'Program_City';
if (orderby == 'asc') orderby = 'desc';
else orderby = 'asc';
callApi(pagenumber);
}
<!--Function used to sort programs by program country-->
function sortbyPrgCountry() {
fieldname = 'Program_Country';
if (orderby == 'asc') orderby = 'desc';
else orderby = 'asc';
callApi(pagenumber);
}
<!--Function used to sort programs by program region-->
function sortbyPrgRegion() {
fieldname = 'Program_Region';
if (orderby == 'asc') orderby = 'desc';
else orderby = 'asc';
callApi(pagenumber);
}
<!--Function used to get program brochure-->
function getProgrambrochure(prgid) {
if (prgid != '') location.href = basesiteurl + '?FuseAction=Programs.ViewProgram&program_id=' + prgid;
}
</script>
<script language="javascript">
callApi(1);
</script>
Example 2: Following is an example of using ColdFusion to call the API and returning the data in a SOAP envelope:
var pagelimit = 10;
var pagenumber = 1;
var numberofpages = '';
var orderby = 'asc';
var fieldname = '';
var searchresultpagecontent = '<div id="programlistcontainer"><div id="container"><div id="main-content"><div class="one-col-row"><div class="c1"><div class="program-block"><div class="list-block"><!--FEATUREDPROGRAM LIST ROWSTART--><div class="featured-programs"><div class="overview"><div class="left"><a href="javascript:void(0)" onclick="getProgrambrochure({FEATUREDPROGRAM_ID})"><!--{FEATUREDPROGRAM_NAME}--></a><br /> <!--{FEATUREDPROGRAM_CITY}-->, <!--{FEATUREDPROGRAM_COUNTRY}--></div><div class="right"><span>Terms:</span> <!--{FEATUREDPROGRAM_TERM}--><br /><span>Partner(s):</span> <!--{FEATUREDPROGRAM_PARTNER}--></div></div><div class="description"><span>Description:</span> <!--{FEATUREDPROGRAM_DESCRIPTION}--></div></div><!--FEATUREDPROGRAM LIST ROWEND--><!--</div>--><div class="list-info">Currently, the listing is showing Outgoing Programs, sorted by <span>Name</span>.</div><!--<div class="list-buttons"><ul><li class="selected"><a href="#">Outgoing</a></li><li><a href="#">Scholarships</a></li></ul></div>--><div class="legend">(F) Featured Programs (Inactive) Program Not Active</div><div class="list-all"><table width="903" border="0" cellspacing="0" cellpadding="2"><thead class="table-head"><tr><th align="left" class="first">Program Name <a href="javascript:void(0)" onclick="sortbyPrgName()">SortByName</a></th><th align="left" valign="middle">City <a href="javascript:void(0)" onclick="sortbyPrgCity()">SortByCity</a></th><th align="left">Country <a href="javascript:void(0)" onclick="sortbyPrgCountry()">SortByCountry</a></th><th align="left">Region <a href="javascript:void(0)" onclick="sortbyPrgRegion()">SortByRegion</a></th></tr></thead><!--PROGRAM LIST ROWSTART--><tr><td align="left" class="{CLASS_NAME}"><a href="javascript:void(0)" onclick="getProgrambrochure({PROGRAM_ID})" title="<!--{PROGRAM_NAME}-->"><!--{PROGRAM_NAME}--></a> <!--{BIT_FEATURED}--></td><td align="left" class="{CLASS_NAME}"><!--{PROGRAM_CITY}--></td><td align="left" class="{CLASS_NAME}"><!--{PROGRAM_COUNTRY}--></td><td align="left" class="{CLASS_NAME}"><!--{PROGRAM_REGION}--></td></tr><!--PROGRAM LIST ROWEND--></table><div class="list-paging" align="center"><span><a href="javascript:void(0)" onclick="gotoprevpage()">«</a></span><!--PAGES START--><span id="pagingclass" class="{PAGING_CLASS_NAME}"><a id="pages" onclick="gotopage(this.innerHTML)" href="javascript:void(0)"><!--{PAGES}--></a></span><!--PAGES END--><span><a href="javascript:void(0)" onclick="gotonextpage()">»</a></span></div></div></div><!--</div>--><!--</div>--><!--</div>--></div></div></div></div><div id="footer" align="center"> By Terra Dotta. Technology for educating the world. Copyright Terra Dotta, LLC. All Rights Reserved. </div></div></div>';
<!--Domain name, API url and site url-->
<!--Base url can be modified corresponding to the University/School-->
var domainname = '<cfoutput>#REQUEST.CurrentAccount.AuthHostDomain()#</cfoutput>';
var baseapiurl = '<cfoutput>#REQUEST.CurrentAccount.AuthHostProtocol()#://</cfoutput>'+domainname+'<cfoutput>#REQUEST.CurrentAccount.AuthHostPort()##REQUEST.CurrentAccount.AuthHostRelativeRoot()#</cfoutput>piapi/index.cfm';
var basesiteurl = '<cfoutput>#REQUEST.CurrentAccount.AuthHostProtocol()#://</cfoutput>'+domainname+'<cfoutput>#REQUEST.CurrentAccount.AuthHostPort()##REQUEST.CurrentAccount.AuthHostRelativeRoot()#</cfoutput>index.cfm';
var programlist ='';
<!--Function used to get url values-->
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
<!--Function used to call program search results API-->
function callApi(pnumber) {
pagenumber = pnumber;
var startrow = (pnumber - 1) * pagelimit;
var endrow = startrow + pagelimit;
<!--Variable contains the program search result content block-->
programlist = searchresultpagecontent;
var url = baseapiurl + '?callname=getProgramSearchResults&ResponseEncoding=json';
var hash = getUrlVars();
var city = '';
var country = '';
var region = '';
var term = '';
if (hash['city']) city = hash['city'];
if (hash['country']) country = hash['country'];
if (hash['region']) region = hash['region'];
if (hash['term']) term = hash['term'];
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url + '&city=' + city + '&country=' + country + '®ion=' + region + '&term=' + term + '&startrow=' + startrow + '&endrow=' + endrow;
if (fieldname != '') {
script.src = url + '&city=' + city + '&country=' + country + '®ion=' + region + '&term=' + term + '&startrow=' + startrow + '&endrow=' + endrow + '&itemSort=' + fieldname + '&sortOrder=' + orderby;
}
head.appendChild(script);
}
function _cb_getProgramSearchResults(root) {
<!--Variables rwString and frwString used to get specific content block-->
rwString = programlist.substring(programlist.indexOf('<!--PROGRAM LIST ROWSTART-->') + 28, programlist.indexOf('<!--PROGRAM LIST ROWEND-->'));
frwString = programlist.substring(programlist.indexOf('<!--FEATUREDPROGRAM LIST ROWSTART-->') + 36, programlist.indexOf('<!--FEATUREDPROGRAM LIST ROWEND-->'));
previousnextString = programlist.substring(programlist.indexOf('<!--PREVIOUS START-->') + 22, programlist.indexOf('<!--PREVIOUS END-->'));
pagingString = programlist.substring(programlist.indexOf('<!--PAGES START-->') + 18, programlist.indexOf('<!--PAGES END-->'));
<!--Variable used to store featured image-->
featuredimage = '(F)';
<!--Below variables used to get program details-->
var progname = '';
var progcity = '';
var progcountry = '';
var progregion = '';
var progid = 0;
var programfeatured = 0;
<!--Variable to append all programs list-->
var appendlist = '';
<!--Variable to append all featured programs-->
var appendfeatured = '';
<!--Variable to append all page numbers-->
var appendpaging = '';
if (root.RECORDCOUNT > 0) {
<!--To get all programs list-->
var rs = root.PROGRAM;
if (rs) {
for (var key in rs) {
var obj = rs[key];
progname = '';
progcity = '';
progcountry = '';
progregion = '';
for (var prop in obj) {
if (prop == 'PROGRAM_NAME') progname = obj[prop];
if (prop == 'PROGRAM_CITY') progcity = obj[prop];
if (prop == 'PROGRAM_COUNTRY') progcountry = obj[prop];
if (prop == 'PROGRAM_REGION') progregion = obj[prop];
if (prop == 'PROGRAM_ID') progid = obj[prop];
if (prop == 'PROGRAM_FEATURED') programfeatured = obj[prop];
}
<!--Replace the custom keywords used in the html content with corresponding values-->
rplcedRow = rwString.replace(/<!--{PROGRAM_NAME}-->/g, progname);
rplcedRow = rplcedRow.replace('<!--{PROGRAM_CITY}-->', progcity);
rplcedRow = rplcedRow.replace('<!--{PROGRAM_COUNTRY}-->', progcountry);
rplcedRow = rplcedRow.replace('<!--{PROGRAM_REGION}-->', progregion);
rplcedRow = rplcedRow.replace('{PROGRAM_ID}', progid);
if (programfeatured == 1) rplcedRow = rplcedRow.replace('<!--{BIT_FEATURED}-->', featuredimage);
else rplcedRow = rplcedRow.replace('<!--{BIT_FEATURED}-->', '');
if (key % 2 == 0) rplcedRow = rplcedRow.replace(/{CLASS_NAME}/g, 'listing-cell');
else rplcedRow = rplcedRow.replace(/{CLASS_NAME}/g, 'listing-cell alternate-row');
appendlist = appendlist + rplcedRow;
}
}
if (root.FEATURED) {
<!--To get all featured programs-->
if (root.FEATURED.FEATUREDRECORDCOUNT > 0) {
<!--Below variables used to get featured program details-->
var featuredprogid = 0;
var featuredprogname = '';
var featuredprogcity = '';
var featuredprogcountry = '';
var featuredprogdesc = '';
var featuredprogterm = '';
var featuredprogpartner = '';
var featuredprogexchange = '';
var progterm = '';
var progpartner = '';
var singleprogterm = '';
var singleprogpartner = '';
var prevprgid = '';
var rs_featured = root.FEATURED.PROGRAM;
if (root.FEATURED.FEATUREDRECORDCOUNT > 1) {
if (rs_featured) {
for (var key in rs_featured) {
if (!rs_featured[key].length) {
var obj = rs_featured[key];
for (var prop in obj) {
if (prop == 'PROGRAM_ID') {
featuredprogid = obj[prop];
}
if (!obj[prop].length) {
if (prop && typeof obj[prop] == 'object') {
var obj1 = obj[prop];
for (var prop1 in obj1) {
var obj2 = obj1[prop1];
for (var prop2 in obj2) {
var obj3 = obj2[prop2];
if (obj2[prop2].length) {
if (prop2 == 'PROGRAM_TERM') {
singleprogterm = obj2[prop2];
featuredprogterm = singleprogterm;
}
if (prop2 == 'PROGRAM_PARTNER') {
singleprogpartner = obj2[prop2];
featuredprogpartner = singleprogpartner;
}
} else {
var progterm = '';
var progpartner = '';
for (var prop3 in obj3) {
if (prop3 == 'PROGRAM_TERM') {
progterm = obj3[prop3];
}
if (prop3 == 'PROGRAM_PARTNER') {
progpartner = obj3[prop3];
}
}
if (featuredprogterm != '') featuredprogterm = featuredprogterm + ',' + progterm;
else featuredprogterm = progterm;
if (featuredprogpartner != '') featuredprogpartner = featuredprogpartner + ',' + progpartner;
else featuredprogpartner = progpartner;
}
}
}
}
} else {
if (prop == 'PROGRAM_NAME') featuredprogname = obj[prop];
if (prop == 'PROGRAM_CITY') featuredprogcity = obj[prop];
if (prop == 'PROGRAM_COUNTRY') featuredprogcountry = obj[prop];
if (prop == 'BEXCHANGEAVAILABLE') featuredprogexchange = obj[prop];
if (prop == 'PROGRAM_DESCRIPTION') featuredprogdesc = obj[prop];
}
}
}
<!--Replace the custom keywords used in the html content with corresponding values-->
frplcedRow = frwString.replace('<!--{FEATUREDPROGRAM_NAME}-->', featuredprogname);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_CITY}-->', featuredprogcity);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_COUNTRY}-->', featuredprogcountry);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_TERM}-->', featuredprogterm);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_PARTNER}-->', featuredprogpartner);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_DESCRIPTION}-->', featuredprogdesc);
frplcedRow = frplcedRow.replace('{FEATUREDPROGRAM_ID}', featuredprogid);
appendfeatured = appendfeatured + frplcedRow;
featuredprogterm = '';
featuredprogpartner = '';
}
}
} else {
if (rs_featured) {
for (var key in rs_featured) {
if (key == 'PROGRAM_ID') featuredprogid = rs_featured[key];
if (!rs_featured[key].length) {
var obj = rs_featured[key];
for (var prop in obj) {
if (prop && typeof obj[prop] == 'object') {
var obj1 = obj[prop];
for (var prop1 in obj1) {
var obj2 = obj1[prop1];
for (var prop2 in obj2) {
if (prop2 == 'PROGRAM_TERM') {
progterm = obj2[prop2];
}
if (prop2 == 'PROGRAM_PARTNER') {
progpartner = obj2[prop2];
}
}
if (featuredprogterm != '') featuredprogterm = featuredprogterm + ',' + progterm;
else featuredprogterm = progterm;
if (featuredprogpartner != '') featuredprogpartner = featuredprogpartner + ',' + progpartner;
else featuredprogpartner = progpartner;
}
}
}
} else {
if (key == 'PROGRAM_NAME') featuredprogname = rs_featured[key];
if (key == 'PROGRAM_CITY') featuredprogcity = rs_featured[key];
if (key == 'PROGRAM_COUNTRY') featuredprogcountry = rs_featured[key];
if (key == 'BEXCHANGEAVAILABLE') featuredprogexchange = rs_featured[key];
if (key == 'PROGRAM_DESCRIPTION') featuredprogdesc = rs_featured[key];
}
}
<!--Replace the custom keywords used in the html content with corresponding values-->
frplcedRow = frwString.replace('<!--{FEATUREDPROGRAM_NAME}-->', featuredprogname);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_CITY}-->', featuredprogcity);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_COUNTRY}-->', featuredprogcountry);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_TERM}-->', featuredprogterm);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_PARTNER}-->', featuredprogpartner);
frplcedRow = frplcedRow.replace('<!--{FEATUREDPROGRAM_DESCRIPTION}-->', featuredprogdesc);
frplcedRow = frplcedRow.replace('{FEATUREDPROGRAM_ID}', featuredprogid);
appendfeatured = appendfeatured + frplcedRow;
}
}
}
}
<!--Variable to get total number of records-->
var totalrecords = root.RECORDCOUNT;
<!--Variable to get total number of pages-->
numberofpages = Math.round(totalrecords / pagelimit);
for (i = 1; i <= numberofpages; i++) {
rplcedPageNumber = pagingString.replace('<!--{PAGES}-->', i);
if (pagenumber == i) rplcedPageNumber = rplcedPageNumber.replace('{PAGING_CLASS_NAME}', 'selected');
else rplcedPageNumber = rplcedPageNumber.replace('{PAGING_CLASS_NAME}', '');
appendpaging = appendpaging + rplcedPageNumber;
}
}
<!--Variables tobereplaced , ftobereplaced and pagingStringtobereplaced used to replace specific content block with corresponding values-->
tobereplaced = programlist.substring(programlist.indexOf('<!--PROGRAM LIST ROWSTART-->'), programlist.indexOf('<!--PROGRAM LIST ROWEND-->') + 26);
ftobereplaced = programlist.substring(programlist.indexOf('<!--FEATUREDPROGRAM LIST ROWSTART-->'), programlist.indexOf('<!--FEATUREDPROGRAM LIST ROWEND-->') + 34);
pagingStringtobereplaced = programlist.substring(programlist.indexOf('<!--PAGES START-->'), programlist.indexOf('<!--PAGES END-->') + 16);
programlist = programlist.replace(tobereplaced, appendlist);
programlist = programlist.replace(ftobereplaced, appendfeatured);
programlist = programlist.replace(pagingStringtobereplaced, appendpaging);
document.getElementById('results').innerHTML = programlist;
}
<!--Function used to get the selected page-->
function gotopage(pnum) {
callApi(pnum);
}
<!--Function used to get the next page-->
function gotonextpage() {
if (pagenumber != numberofpages) pagenumber = pagenumber + 1;
else pagenumber = pagenumber;
callApi(pagenumber);
}
<!--Function used to get the previous page-->
function gotoprevpage() {
if (pagenumber != 1) pagenumber = pagenumber - 1;
else pagenumber = pagenumber;
callApi(pagenumber);
}
<!--Function used to sort programs by program name-->
function sortbyPrgName() {
fieldname = 'Program_Name';
if (orderby == 'asc') orderby = 'desc';
else orderby = 'asc';
callApi(pagenumber);
}
<!--Function used to sort programs by program city-->
function sortbyPrgCity() {
fieldname = 'Program_City';
if (orderby == 'asc') orderby = 'desc';
else orderby = 'asc';
callApi(pagenumber);
}
<!--Function used to sort programs by program country-->
function sortbyPrgCountry() {
fieldname = 'Program_Country';
if (orderby == 'asc') orderby = 'desc';
else orderby = 'asc';
callApi(pagenumber);
}
<!--Function used to sort programs by program region-->
function sortbyPrgRegion() {
fieldname = 'Program_Region';
if (orderby == 'asc') orderby = 'desc';
else orderby = 'asc';
callApi(pagenumber);
}
<!--Function used to get program brochure-->
function getProgrambrochure(prgid) {
if (prgid != '') location.href = basesiteurl + '?FuseAction=Programs.ViewProgram&program_id=' + prgid;
}
</script>
<script language="javascript">
callApi(1);
</script>
Run Example 2 Top
(if your installation does not have any data, this example will not return anything)
<!---// local variables //--->
<cfparam name="responsePacket" default="[ no response ]" />
<!---// connect to the API (GET or POST) //--->
<cfhttp result="httpCall" method="post" url="#REQUEST.CurrentAccount.AccountURL()#piapi/index.cfm">
<cfhttpparam name="callName" type="url" value="getProgramSearchResults" />
<cfhttpparam name="ResponseEncoding" type="url" value="SOAP" />
</cfhttp>
<!---// ensure the response is in XML format //--->
<cfif isXml(httpCall.fileContent)>
<!---// parse response //--->
<cfset responsePacket = xmlParse(httpCall.fileContent) />
<!---// check to see if an error was thrown //--->
<cfset err = xmlSearch(responsePacket, "//extrainfo") />
<!---// an error was thrown //--->
<cfif isArray(err) and not arrayIsEmpty(err)>
<!---// throw error //--->
<cfthrow message="#err[1].xmlText#" />
<cfabort />
</cfif>
<cfelse>
<!---// additional error checking //--->
</cfif>
<!---// additional code goes here //--->
<h2>Output for 'responsePacket':</h2>
<cfdump VAR="#responsePacket#" />
<cfparam name="responsePacket" default="[ no response ]" />
<!---// connect to the API (GET or POST) //--->
<cfhttp result="httpCall" method="post" url="#REQUEST.CurrentAccount.AccountURL()#piapi/index.cfm">
<cfhttpparam name="callName" type="url" value="getProgramSearchResults" />
<cfhttpparam name="ResponseEncoding" type="url" value="SOAP" />
</cfhttp>
<!---// ensure the response is in XML format //--->
<cfif isXml(httpCall.fileContent)>
<!---// parse response //--->
<cfset responsePacket = xmlParse(httpCall.fileContent) />
<!---// check to see if an error was thrown //--->
<cfset err = xmlSearch(responsePacket, "//extrainfo") />
<!---// an error was thrown //--->
<cfif isArray(err) and not arrayIsEmpty(err)>
<!---// throw error //--->
<cfthrow message="#err[1].xmlText#" />
<cfabort />
</cfif>
<cfelse>
<!---// additional error checking //--->
</cfif>
<!---// additional code goes here //--->
<h2>Output for 'responsePacket':</h2>
<cfdump VAR="#responsePacket#" />
For additional techniques, be sure to visit the other program calls within these documentation pages.
Back to Terra Dotta Software API Documentation Top