Technical Support
posted this on May 22, 2009 11:14
You can implement any external program in the language you feel more comfortable with in order to create plugins that interact with TouristWay to extend the set of information available in any page (portlets).
In other word, TouristWay can pass information about the currently-displayed page to an external program and use its response in the page.
What TouristWay expects is an XML output, each field (element) of this XML tree will be accessible as it was generated by TouristWay components.
The nuts and bolts of the underlying process are described in paragraph 2.6 (COMPONENT “WIDGET” AND WEB SERVICES) of the Component Reference Guide (see http://support.touristway.com/forums/30687/entries/21760), but should you like to start with a basic example here's one.
First of all place the attached file "dummy.cgi" in the folder "plugins" of your TouristWay installation. Make sure you give it the very same ownership and permissions of any other file in the same folder.
DUMMY.CGI is a very basic script written in Perl to parse an XML input and return it along with few test variables.
You can try DUMMY.CGI without using TouristWay by calling it from your Internet browser (mind to change the URL with your server name!):
http://www.mytravelsite.com/plugins/dummy.cgi
or, through a command-line client such as Curl (http://curl.haxx.se) in order to pass an XML:
curl -d @samplepost.xml -H 'Content-Type: text/xml' -X POST http://www.mytravelsite.com/plugins/dummy.cgi
The file "samplepost.xml" contains the input you want to send and might look like this (it's also attached to this article)
<touristway>
<test>
<myvariable>123</myvariable>
</test>
<onemore>
<hello>world</hello>
</onemore>
</touristway>
Finally you can call DUMMY.CGI from a TouristWay widget, place this in the COMPONENTS node of your index.html page (or any other you prefer):
<component id="mywebservice" class="widget">
<pluginuri>http://www.mytravelsite.com/plugins/dummy.cgi</pluginuri>
<whatever>Hello</whatever>
<onemore>World</onemore>
<datasetalias>
<alias id="userdata">account</alias>
<alias id="theform">form</alias>
</datasetalias>
</component>
Then call the page from your browser by adding the debug=D parameter to display the data tree (http://www.mytravelsite.com/twpub/index.cgi?debug=D).
Go to the bottom of the page, select the component "mywebservice" from the list and dig into the inner nodes to see how the output of DUMMY.CGI got imported in TouristWay. You can also access from the template any of the new variables just by repeating their path in the tree:
%-components.mywebservice.plugin.mystring-%
Please remember that you can create your DUMMY.CGI (hopefully using a different name) in any language. PHP, ASP, Ruby are all fine as long as you can make them read and create XML strings.