Reputation: 49
i create a controller like this in folder controllers yii basic
<?php
namespace app\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
class HelloController extends Controller
{
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
];
}
public function actionIndex()
{
echo "Hello World";
}
public function actionPosts($id=0, $category="all")
{
echo "Sedang menampilkan postingan dengan id: ".$id;
}
public function actionPostComments($id)
{
echo "Sedang menampilkan komentar dari postingan dengan id: ".$id;
}
public function actionUserPosts($user_id, $bulan, $tahun)
{
echo "Sedang menampilkan daftar postingan dari user dengan id ".$user_id." dengan arsip ".$bulan." / ".$tahun;
}
}
but when i try to call the function actionUserPosts with this link
http://localhost/hello-yii/web/index.php?r=hello/user-posts?user_id=10&bulan=2&tahun=2017
the result is Not Found (#404)
what's wrong with this?
Upvotes: 0
Views: 93
Reputation: 921
Change your Url like this
http://localhost/hello-yii/web/index.php?r=hello/userPosts&user_id=10&bulan=2&tahun=2017
? is use only first time when variable pass in url and then & sign.
Upvotes: 3