I am writing my first Piwik plugin. Its purpose is to force every widget on the site to have a particular “segment” parameter in its URL (if none exists already). So all URLs of the form:
http://example.com/piwik/index.php?module=Foo&action=bar&idSite=2&…
would automatically become (for example):
http://example.com/piwik/index.php?module=Foo&action=bar&idSite=2&…&segment=pageTitle!=Home
What is the correct hook that lets me access this information and modify it? I tried the hook Controller.renderView, which provides me with a ViewDataTable object, but I could not figure out how to modify the URL or API call from here.
Given the correct hook, I am hoping this plugin will take only a few lines to write, looking something like this:
class Piwik_MyStuff extends Piwik_Plugin {
//...
public function getListHooksRegistered() {
return array( 'The.Right.Hook' => 'MyCallback' );
}
function MyCallback($x) {
$stuff = $x->getTheNeededStuff(); // Magic. :-)
$stuff['segment'] = 'pageTitle!=Home';
}
}
Any advice on how to implement this?
Thank you very much.