I’m new to Yii. I have a controller like this:
<?php
class EventsController extends Controller
{
public function actionIndex()
{
$this->render('index');
}
}
How can i make the following url render the correct view. eg.
localhost/events/intaglio -> $this->render('intaglio');
localhost/events/burrito-> $this->render('burrito');
localhost/events/jerrito -> $this->render('jerrito');
Worse case, I’ll have to have separate actions for each
public function actionIntagio {...}
public function actionBurrito {...}
public function actionJerrito {...}
Is there a smarter way of doing this?
Setup URL rules (in protected/config/main.php) to handle those URL’s dynamically, eg:
This points any URL with events/whatever to the Controller/Action events/myaction. You can then access the
event_nameportion of the URL with a$_GETvariable, eg: