Formating urls in yii1

2019-09-12 05:57发布

I have a url http://test.site.loc/profile/membership/view/id/1> I do not know how to format it in such a way that if I type http://test.site.loc/profile/membership/view/1, it will direct the same url. Please, help me.

标签: yii
1条回答
放我归山
2楼-- · 2019-09-12 06:31

You can create your URL in 'URL Manager' like

'/profile/membership/view/<id>' => '/profile/membership/view'

which will route you to 'view' action and you can get 'id' with following code

Yii::app()->request->getParam('id');

and create your URL as follows

echo CHtml::link("Label",
     Yii::app()->createUrl(
             '/profile/membership/view', 
             array(
                 'id'=>1 
             )
     )
);
查看更多
登录 后发表回答