Closed jsobers1331 closed 8 years ago
Hi, if you use the advanced template, you can place this code in the main config for the your backend application. For example, you can place this code after this line. You can then access to comments management section through the following URL: your-backed-application-url/comments/index
I'm accessing the backend comments sections just fine. I want to modify the code you have in the Default Controller. But it's not picking up my file. Still using yours, even when i did your suggestion above.
Do you want override the ManageController
?
Yes
Ok, you can create your own controller for example
namespace app\controllers;
class ManageController extends \yii2mod\comments\controllers\ManageController
{
// your custom index action
public function actionIndex()
{
}
}
And then edit the config:
'controllerMap' => [
'comments' => 'app\controllers\ManageController' // your own controller
],
I did that but it didn't work. i placed it after the module section in main config like you suggested and it didn't work. Before i had placed it in the module config like:
'comment' => [
'class' => 'yii2mod\comments\Module',
'controllerMap' => [
'DefaultController' => 'frontend\controllers\comments\DefaultCommentController'
],
],
and it didn't work like this either.
Ok, now i understand. If you want override the yii2mod\comments\controllers\DefaultController
you can do it by the following code:
1) Create your own DefaultController
<?php
namespace app\controllers;
use Yii;
class DefaultController extends \yii2mod\comments\controllers\DefaultController
{
// your custom create comment action
public function actionCreate($entity)
{
}
}
2) Modify config
'modules' => [
'comment' => [
'class' => 'yii2mod\comments\Module',
'controllerNamespace' => 'app\controllers' // namespace for the your default controller
],
],
Thank you i got it to work i think.
I've tried the following below to override your controller and it didn't work.
Can you explain to me where exactly in the main config file i should place this code? I see no admin module section in this file. I'm using yii2 advanced .
Thanks.