Hi Every one, I am new to piwik.Please help me in my issue.
Issue: I have to create 4 levesl of subtables.Currently I can able to create upto 2nd level,I mean table with one subtable per row. Basically If I click on a table row I shoud get the subtable.If I click on subtable row again it should show inner subtable. I need to create Table->subtable->subtable->subtable.
My code :
function getpageViewsLevel1($idSite, $date, $period)
{
$query = "select * from....";
$result = Piwik_FetchAll($query, array($idSite, $dateStart, $dateEnd));
// convert this array to a DataTable object
$dataTable = new Piwik_DataTable();
//Add subtable to each result
foreach ($result as $arr){
$piwik_row = new Piwik_DataTable_Row;
$piwik_row->setColumns($arr);
$subDataTable = new Piwik_DataTable();
$piwik_row->addSubTable($subDataTable);
$dataTable->addRow($piwik_row);
}
return $dataTable;
}
function getpageViewsLevel2($idSite, $date, $period, $idSubtable)
{
// Find selected parent row and retrieve data
$dataTable_old = $this->getpageViewsLevel1($idSite, $date, $period);
$row_old = new Piwik_DataTable_Row;
$row_old=$dataTable_old->getRowFromIdSubDataTable($idSubtable+1);
$tmp=$row_old->getColumns();
//Using $actionName in DB Query
$actionName=$tmp['pageTitle'].'%';
//db query
$query = "select * ....";
$result = Piwik_FetchAll($query, array($idSite, $dateStart, $dateEnd, $actionName));
// convert this array to a DataTable object
//$dataTable = new Piwik_DataTable();
foreach ($result as $arr){
$piwik_row = new Piwik_DataTable_Row;
$piwik_row->setColumns($arr);
$subDataTable = new Piwik_DataTable();
$piwik_row->addSubTable($subDataTable);
$dataTable->addRow($piwik_row);
}
return $dataTable;
}
Till here works fine.For the 3rd level,I am not able to apply the same logic as I dont have the 2ng level table ID.
function getpageViewsLevel3($idSite, $date, $period, $idSubtable)
{
// Find selected parent row and retrieve data
$dataTable_old = $this->getpageViewsLevel2($idSite, $date, $period, ___???????????????);
Please help me how can I proceed with this issue.Please let me know is there any other solution to do this. Though if I pass some number like '1' for testing,
$dataTable_old = $this->getpageViewsLevel2($idSite, $date, $period, 1);----->this is not working.
I need to use parent row info in my DB query.
Thanks in advance for your help.