Yii How to render Page NAME instead, ID in URL

158 views Asked by At

I want to render page name through URL request parameter.

like -

r=page/view&name=page_name

instead of id - r=page/view&id=1

please i need to know what i can do in
actionview(), viewfile and urlmanager (code generated by gii)

Help to resolve my issue.

1

There are 1 answers

2
Rohit Suthar On

You can do like this -

your request url - r=page/view&name=page

In your action controller -

public function actionView(){

   if(isset($_REQUEST['name']) && !empty($_REQUEST['name'])){

    $page_name = $_REQUEST['name'];
    $this->render($page_name);
   }
}