0
개발 중에 urlManager를 사용하여 하나의 문제에 직면했습니다.Yii2, 루스터의 선택적 매개 변수
SiteController에 "category"동작이 있습니다. 이 작업을 사용할 수 있습니다
public function actionCategory($id = null, $city = null, $location = null)
{
echo $id;
echo $city;
echo $location;
}
모든 가능한 조합 :
id, city, location = null
id, city = null, location
id, city = null, location = null
id = null, city = null, location = null
id = null, city = null, location
나는 그 후 난 후 변수에 다음 값을 얻을 것이라고 UrlManager의 규칙을 작성하는 방법을 모른다 링크를 누르십시오 :
<h4><?= Html::a('ID City', ['/site/category', 'id' => 'barbershop', 'city' => 'Praha'], ['class' => 'btn btn-primary']) ?></h4>
The return value from "category" action:
id = 'barbershop'
city = 'Praha'
location = ''
<h4><?= Html::a('ID Location', ['/site/category', 'id' => 'barbershop', 'location' => '23,65'], ['class' => 'btn btn-primary']) ?></h4>
The return value from "category" action:
id = 'barbershop'
city = ''
location = '23,65'
<h4><?= Html::a('ID', ['/site/category', 'id' => 'barbershop'], ['class' => 'btn btn-primary']) ?></h4>
The return value from "category" action:
id = 'barbershop'
city = ''
location = ''
<h4><?= Html::a('City', ['/site/category', 'city' => 'Praha'], ['class' => 'btn btn-primary']) ?></h4>
The return value from "category" action:
id = ''
city = 'Praha'
location = ''
<h4><?= Html::a('Location', ['/site/category', 'location' => '14,23'], ['class' => 'btn btn-primary']) ?></h4>
The return value from "category" action:
id = ''
city = ''
location = '14,23'
이 문제와 관련해 도와 주시겠습니까?