Home Analytics DevShare
The community of Analytics developers are invited to follow and participate in the developer network.
OpenText technical experts collaborate with supported customers and partners in the Magellan product area.

HOWTO: Create a BVT Template for PHP

kclarkkclark BIRT GuruEM
edited January 10, 2014 in DevShare
The Birt Viewer Toolkit (BVT) is a new free viewer for the BIRT developer community. One of it's strengths is the JavaScript API (JSAPI). By making use of the JSAPI we can easily create a template that can be reused in your PHP Project to embed your BIRT reports. If you're unfamiliar with the Smarty project, I suggest taking a look at their website.<br />
<br />
Once BVT is installed on your application we'll use the following code for the template.
&lt;BODY onload="init()"&gt;
&lt;script type='text/javascript' language='JavaScript' src="http&#58;//localhost:8080/birt/jsapi"&gt;&lt;/script&gt;
&lt;script type='text/javascript'&gt;
function init( ){
actuate.initialize( "http&#58;//localhost:8080/birt", null,null,null,myInit );
function myInit(){
viewer1 = new actuate.Viewer( 'container1' );
viewer1.submit( );
Hello {$name}!
&lt;div id='container1' style=' border-width: 1px; border-style: solid;' /&gt;
<br />
If you're familiar with PHP you'll notice I've use variable for name, height, and width to make this template dynamic. This will allow for easier changes down the road when you want to embed another report somewhere else. Now that we've got the template we can use it in some PHP using the following.

// put full path to Smarty.class.php
$smarty = new Smarty();


$smarty-&gt;assign('name', 'test.rptdesign');
$smarty-&gt;assign('height', '750');
$smarty-&gt;assign('width', '800');
<br />
If all went well you should have a report that is embedded inside your PHP page. If you need to find some more information on Actuate's JSAPI or have any questions make sure to check out the deployment center or ask on the forums.

Kristopher Clark

Actuate Corporation – The BIRT Company™

http://www.actuate.com | http://birtondemand.com


My Blog



Sign In or Register to comment.