Frage

My module called Test, and a back-office controller to this is check, here is the code

class TestCheckModuleAdminController extends ModuleAdminController {

    public function __construct()
    {

        echo "Checked!";

    }

}

And when I'm going to mysite/admin/index.php?controller=check&module=test I'm getting the message that it doesn't exists, so whats went wrong?

I'm even turned on valid urls for it and it must be like this:

mysite/admin/module/test/check but no response to this.

Though if it is a Front Controller like this:

class TestCheckModuleFrontController extends ModuleFrontController {

    public function __construct()
    {

        echo "Checked Front!";

    }

}

url for this will be like mysite/module/test/check and it's allright.

I guess that it is no rewrite rules for this in .htaccess

I tried this...

RewriteCond %{HTTP_HOST} ^test.test$
RewriteRule ^admin([0-9]{4})/module/([a-z]+)/([a-z]+) module=$1&controller=$2 [L]

maybe it's not right, but close to the answer.

upd 1.

prestashop/modules/mymodule/controllers/admin/check.php

and it's source right now:

class TestCheckController extends ModuleAdminController {

    public function __construct()
    {   
        echo "Checked!";
    }

}

What url I must to use for it?

upd 2. Well, I have a new tab in my admin/tabs list. But still can't go a controller on it.

russian panel

What I can do with this tab btw? Maybe I can put it anywhere on admin menu isn't?

check

How can get this check controller from a url than?

War es hilfreich?

Lösung

For the name you should just write TestCheckController instead of TestCheckModuleAdminController. I did it recently and it works for me.

You can also extend the Prestashop menubar in the way you won't need to provide a token by yourself:

in you module install method, add the following code:

$parentTab = new Tab();
$parentTab->name[$this->context->language->id] = $this->l'('My module Top tab');
$parentTab->class_name = 'TopModuleNav';
$parentTab->id_parent = 0;
$parentTab->module = $this->name;
$parentTab->add();

$adminMenuItem = new Tab();
$adminMenuItem->name[$this->context->language->id] = $this->l'('Admin Menu Item');
$adminMenuItem->class_name = "TestCheck";
$adminMenuItem->module = $this->name;
$adminMenuItem->id_parent = $parentTab->id;
$adminMenuItem->add();

I hope it helps!

Andere Tipps

At BackOffice your controller is "TestCheckModule" so you should call it via:

admin/index.php?controller=TestCheckModule&token=xxxxxxxxxxxxxxxxxxxxxxxxxxx

you should provide a proper token as well.

You do not need to provide the module name in the URL.

It's a good practice to prefix the controller with "Admin"

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top