Action not defined error in custom controller

I wanted to create a custom plugin for custom reports sharing. I have created a new page for it as mentioned at How to add new pages and menu items to Piwik – Introducing the Piwik Platform - Analytics Platform - Matomo

Now, I am getting action not defined error when I try to upload custom file to controller. I checked from URL and found that http://localhost/matomo/index.php?module=CustomReportSharing&action=index is accessible but http://localhost/matomo/index.php?module=CustomReportSharing&action=index1 not accessible. Although both function have been defined in controller i.e., CustomReportSharing

Please guide me why no action is accessible other than index.
Here is code snippet.

namespace Piwik\Plugins\CustomReportSharing;
class CustomReportSharing extends \Piwik\Plugin
    public function index()
        return $this->renderTemplate('index', array( 'answerToLife' => 42));
    public function index1()
            return $this->renderTemplate('index', array('answerToLife' => 46 ));

The problem has been solved. In fact I have defined the action i.e. function in CustomReportSharing.php file which was not correct position. Now, I have written the above mentioned method in Controller.php in plugin/customReportSharing plugin and problem is solved.

1 Like