Right Configuration But Still 404 When I Added An Item To Menu (Yii2.0)

The steps:

1: I added an item named "manageservice" to menu in "frontend/views/layouts/main.php".


            $menuItems = [

                ['label' => 'index', 'url' => ['/site/index']],

                ['label' => 'about, 'url' => ['/site/about']],

                ['label' => 'manager', 'url' => ['/site/manageservice']],

//                ['label' => 'Contact', 'url' => ['/site/contact']],

            ];

2: Added a php file named "manageservice.php" into folder "frontend/views/site".

3:added a function to "SiteController.php" (locat in "frontend/Controllers/"):


    public function actionManageService()

    {

        return 'test';

//        return $this->render('manageService');

    }

then i click "manager" button , i got

"Not Found (#404)

Unable to resolve the request: site/manageservice "

i don’t know where is my mistake or the yii’s bug.

The issue is that your action name is actionManageService. Note uppercase S. For such action the route is manage-service and not manageservice. It’s pointed out in documentation.

thanks, it was solved.

i have the same problem, in my PlanificacionController i have this function:




 public function actionPdf()

{

  

  $pdf = Yii::$app->pdf;

  //Returns the HTML content and put it in the PDF content

  $pdf->content = $this->renderPartial('dinamicoTotal',[]);

  return $pdf->render();

}



this is my view




<?=

     

     '<table width="200" border="1">

  <tr>

    <td>&nbsp;</td>

    <td>&nbsp;</td>

    <td>&nbsp;</td>

  </tr>

  <tr>

    <td>&nbsp;</td>

    <td>&nbsp;</td>

    <td>&nbsp;</td>

  </tr>

  <tr>

    <td>&nbsp;</td>

    <td>&nbsp;</td>

    <td>&nbsp;</td>

  </tr>';?>



in my index i created this button


<?= Html::a(Yii::t('app', 'pdf'),['dinamicoTotal'],['class' => 'btn btn-success'])?>

but when i click it i’ve got “page not found”

what i’m doing wrong? i’m tryng to export this view to pdf file

@epulgaron

The syntax for generating hyperlink tag [color="#333333"]is


Html::a($text, $url = null, $options = [])

. so, in your case, it would be


<?=Html::a(Yii::t('app', 'pdf'),['pdf'],['class'=> 'btn btn-success'])?>

[/color]