Mashups

Mashing up pieces of a page to create complex applications is very easily done in Tequila, you can do this in server side or in client side.

RRT

Requested response type is a parameter normally passed in the URL that indicates Tequila the kind of content the user wants to get, this provides versatility as you can get the same code as a block, a complete page, a page without headers (but with HTML headers), excel, open office, XML (for some methods).

Mashing up on the server

To mashup content in the server you need

  • A complex page that include many blocks

  • Simple pages with the blocks you want to include

In the complex page:

  • Add a placeholder for each block

  • Get the block content using the function getBlock($taskname, $params)

  • Assign to the placeholder using normal template functions

1 // Get users page 2 // Parameters are formatted like the querystring 3 $block = getBlock("users", "mode=Browse&alphabet=A"); 4 $this->template->assign("myblockplaceholder",$block);

In the simple page, you can modify the controller to read also parameters

1 $startwith = getParam("alphabet"); 2 if (!$startwith) 3 { 4 $startwith = safeRequest("alphabet"); 5 }

Mashing up on client side

For the client side you normally need a combination of Javascript and to return HTML code without headers, you can use any JS framework or library you like for this purpose or use Tequila Ajax libraries

You don't need to modify anything on the server side, you simply call

rrt=block/bl or rrt=nh

block/bl works better for DIV while nh (no headers) works better with iframes

Don't worry about your language resources and Javascript includes, they are cached by Tequila so they don't messup your content you will get them in nh only.

JS Code

1 function viewusers(startwith) 2 { 3 url = 'index.php?task=users&mode=Browser&rrt=bl&table='+startwith; 4 var ajax = new AJAXTextAction(url, setlayercontent, 'div_users'); 5 ajax.doGet(); 6 7 }

XML content

XML is not really mashing up, is a more proper application, for XML content you can call any of the inbuilt methods

- Save

@todo next release: Browse, delete, get

Simply by changing the rrt to xml

* Ajax saving already included in Tequila consist of Javascript methods to:

  • Retrieve values from any form

  • Submit using AJAX

  • Process in server

  • Return an XML reply

  • Display the result

Additionally it can show a 'working' text or image (check ajax.js file for details)

If you need your own data in XML just call the appropiate rrt to set the headers and output the xml as you want

rrt = XML will load no templates

rrt = XMLT will load the template in case you use the template file for the XML

Easier XML content.

You can also just call a strategy to make your PHP objects XML, currently you can use:

  • view_xml_status: For Success/Failure, True/False calls

  • view_xml_data: Objects -> XML