[Plugin] Calling the API with parameters


After looking carefullly at the source code I think I understand how to create DataTables for plugins using specific views like this :

$view = Piwik_ViewDataTable::factory();
$view->init( $this->pluginName,  __FUNCTION__, "CustomVariables.getCustomVariables", "getCustomVariablesValuesFromNameId" );

So, if I understand well, it’s in the init method that we call the right API, which is CustomVariables.getCustomVariables.

But the thing is, with the rest API we can specify lot of parameters, like segment (http://piwik.org/docs/analytics-api/reference/#toc-module-customvariables) and other parameters with other methods.

In PHP, with this init method, how am I supposed passing this segment parameter, or more generaly, with any method how am I supposed passing them parameters?

I’ve checked the Piwik_ViewDataTable::setCustomParameter() but it doesn’t seem to work or to do what I think it’s doing.

Parameters will be read from the current query string, and set to the API if the names match. Does that help?

I already tried that passing a third element to the array used to build the menu, like this:

Piwik_AddMenu('General_Visitors', 'IPv6 Usage', array('module' => 'IPv6Usage', 'action' => 'index', 'segment' => 'pageUrl@=foo'));

It works fine but when I go to another module the segment parameter stays in the url and then all my stats are segmented.