This example shows a request which returns a HTML formatted response using an HTML/PHP template. This request could be called by when a partial or full web page is expected in response. It could be used to load an entire web page or be used as a content block in another web page.
Test the example: http://kerkness.ca/kerkdemo/hello.universe
Example 2
If you haven’t already create the directory kerk/modules/hello
Inside the ‘hello’ directory create the file ‘universe.php’ and add the following to it.
<?php
// Tell kerkness that this request should return an HTML response
$kerk->setResponseFormat('HTML');
// Set the template for this request
$kerk->setTemplate( 'hello.universe' );
// Add some content to the request object
$kerk->addContent('myVar', 'Hello Universe');
?>
Create the director kerk/templates/hello
Inside the ‘kerk/templates/hello’ directory create the file ‘universe.php’ and add the following to it
<b>This is the template for hello.universe</b><br/>
<?php print $myVar ?>
Now you can make a request for this service by calling http://kerkness.ca/kerkdemo/hello.universe and see the following response:
This is the template for hello.universe
Hello Universe
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.