Jump to content

I'm failing to understand PS admin module controllers...


Recommended Posts

I'm trying to create a Prestashop 1.5 module, which so far i can install, and it creates a root tab on the admin menu bar.

 

I'm a bit new to the controller convention, and just trying to create a controller for one of the menu items below my root menu, which is called Reporting

 

My controller is located at the following path:

 

modules/printspec/controllers/admin/reporting.php

 

and inside I have the following code:

 

 

<?php

class PrintspecReportingModuleAdminController extends ModuleAdminController
{
public function initContent()
{
	parent::initContent();
	$this->setTemplate('report.tpl');
}
}

 

and I'm trying to access it with the following URL:

 

http : //mydomain.com/admin12345/index.php?controller=PrintspecReporting&token=...

 

What am I misunderstanding and getting wrong here? PrestaShop says:

 

The controller PrintspecReporting is missing or invalid.

Edited by [email protected] (see edit history)
Link to comment
Share on other sites

Did some changes, but my controller still hasn't been found. :(

 

Following the link above, I changed my controller filename to AdminReporting.php, which contains:

 

 

<?php

class AdminReportingController extends ModuleAdminController
{
   /**
    * Constructor
    */
   public function __construct()
   {
       parent::__construct();
   }

   /**
    * initContent
    */
   public function initContent()
   {
       parent::initContent();
       $this->setTemplate('report.tpl');
   }
}

 

I'm trying to access it with the following URL:

 

http : //mydomain.dev/admin12345/index.php?controller=AdminReporting&token=...

 

Any idea why it's been reported as not found or invalid?

Link to comment
Share on other sites

  • 2 years later...

Hey 

How do you fixed it , My code is as follows :
 

<?php
class AdminTokenController extends ModuleAdminController {
    public function initContent() {
 
echo 'hi';
die;
        parent::initContent();
        
        // get a value from the GET request
        $code = strval(Tools::getValue('myvalue'));
        
        // try to add it to the configuratoion:
        if ($code && Configuration::updateValue('IS_VALUE', $code)) {
            echo "Thanks";
        } else {
            echo "Error.";
        }
    }
Edited by Webexpert Rvtech (see edit history)
Link to comment
Share on other sites

  • 2 months later...
  • 8 months later...

Hi,

 

   I too have the same issue. I tried adding menu from back office. Then if I have selected the home as parent its again giving me the error "class not found". After adding menu as sub menu of any other tab the error is not there but shows a white screen nothing else. Please explain if you have got a solution.

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

    My issue of displaying white page is solved. It was due to the error in loading tpl file. Errors will be hidden if its not in development mode. You can enable it in define.inc.php file in config folder.

 

if (!defined('_PS_MODE_DEV_')) {
define('_PS_MODE_DEV_', true);
}

 

It will be false by default. I got the error after enabling it.

Edited by annaarun (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...