<?php
/*
* @author Martin Barker
* @comment This system was built for zend framework however will work without
* if this was in a Zend_Framework application $data could be an instance of
* Zend_Db_Table_Abstract from a query
*/
// load required files
require_once("Singleton.php");
require_once("RenderTable.php");
// get new instance of class
$rt = RenderTable::GetInstance(true);
// setup some dummy data
// please note the use of case on the column names this is how they will be outputted however
// for CSS they will use a lowercase version spaces will be converted to _
// E.G ul.table li.row ul. li.web_site
$data = array(
array(
"id" => 0,
"Name" => "Martin Barker",
"Age" => "25",
"webaddr" => "http://www.allheavymetal.net/",
"Profile" => "View Profile...",
"Web Site" => "Visit Site..."
),
array(
"id" => 1,
"Name" => "Example User",
"Age" => "30",
"webaddr" => "http://www.example.com",
"Profile" => "View Profile...",
"Web Site" => "Visit Site"
)
);
// set the table title used for CSS ul.table.example_table
// second value is whether to show the title of the table or not
$rt->setTitle("Example Table", true);
// provide the data for rendering
$rt->setContent($data);
// set a href rule
// will detect :// and change to a _blank link for external links
// will use array and all rules append to the array
$rt->setHrefRule("Profile", "/view/profile/name/{Name}");
// you can also provide the rules as an array again these will be prepended to the rules array
$rt->setHrefRule(array(
"Web Site" => "{webaddr}"
));
// set hidden column
$rt->setHidden("id"); // will append to a list of columns so can be called multiple times
// or hide a set of columns again will append to list
$rt->setHidden(array(
"webaddr"
));
?>
|