Чтобы написать собственный Piwik плагин Я следую учебник: http://piwik.org/blog/2014/09/create-widget-introducing-piwik-platform/Расширение Piwik для доступа ко всем данным запроса
Как я могу получить доступ к данным запроса, Piwik получает в плагине?
Sample виджет сверху ссылка:
class Widgets extends \Piwik\Plugin\Widgets
{
/**
* Here you can define the category the widget belongs to. You can reuse any existing widget category or define your own category.
* @var string
*/
protected $category = 'ExampleCompany';
/**
* Here you can add one or multiple widgets. You can add a widget by calling the method "addWidget()" and pass the name of the widget as well as a method name that should be called to render the widget. The method can be defined either directly here in this widget class or in the controller in case you want to reuse the same action for instance in the menu etc.
*/
protected function init()
{
$this->addWidget('Example Widget Name', $method = 'myExampleWidget');
$this->addWidget('Example Widget 2', $method = 'myExampleWidget', $params = array('myparam' => 'myvalue'));
}
/**
* This method renders a widget as defined in "init()". It's on you how to generate the content of the widget. As long as you return a string everything is fine. You can use for instance a "Piwik\View" to render a twig template. In such a case don't forget to create a twig template (eg. myViewTemplate.twig) in the "templates" directory of your plugin.
*
* @return string
*/
public function myExampleWidget()
{
$view = new View('@MyWidgetPlugin/myViewTemplate');
return $view->render();
}
}
Как получить доступ в плагине к Piwik данных получает для каждого запроса посетителя, такие как поля заголовка запроса?
код, который вы отправили, нужно ли его содержать внутри плагина? –
@ blue-sky метод в моем сообщении - единственный метод, который работает с заголовками, но поскольку он не решает вашу задачу, вы можете получить доступ к заголовкам непосредственно из плагина через этот вызов '$ _SERVER ['HTTP_MY_TEST_HEADER'] ' – Axalix
код, который вы опубликовали, может быть запущен за пределами плагина? –