Plugin Development: Table object seems not to be created

Hi folks,

we are a group of german students who have the task to develop a plugin for piwik that shows a table of the out-/inbounds of a specific page of the analyzed website.

Our current problem:
The plugin has a widget that calls the following method from the “OutboundsPlugin_Controller”-class


function getOutbounds($fetch = false)
	{		
		$view = Piwik_ViewDataTable::factory();
		$view->init($this->pluginName, __FUNCTION__, 'OutboundsPlugin.getOutbounds' );
		
		$view->setSortedColumn('nb_hits');
		$view->setColumnsToDisplay(array('label', 'nb_hits'));
		$view->setColumnTranslation('label', Piwik_Translate('Outbounds_ColumnOutbounds'));
		$view->setColumnTranslation('nb_hits', Piwik_Translate('General_ColumnHits'));
		$view->setLimit(5);
		return $this->renderView($view, $fetch);
	}	

The API method called by the “init”-method of “ViewDataTable”-class is as following:


public function getOutbounds( $idSite, $period, $date, $expanded = false, $idSubtable = false )
	{
		$dataTable = new Piwik_DataTable();
		$dataRow = new Piwik_DataTable_Row(array('label'=>"page test 1",'nb_hits'=>12));
		$dataRowTwo = new Piwik_DataTable_Row(array('label', 'page test 2','nb_hits', '15'));
		$dataTable->addRow($dataRow);
		$dataTable->addRow($dataRowTwo);
		return $dataTable;
	}

With the API-function we create a simple PIWIK data table with some sample values. The table has two columns with the headers “label” and “hits”.

If we load the Piwik dashboard we only see the table with two rows but not the values we added to the data table in the API method.

In the attachment is a screenshot of the current dashboard frontend.

Has anyone an idea what’s going wrong.

Thanks!

I recommend to look at example in the ExampleUI plugin (you can enable it in the Piwik plugins page).

For example see the code in: plugins/ExampleUI/API.php

oh yeah, it works!
I adopted it for my purposes and now it works.
Thank you :wink: