yii - urlmanager doesn't route to the desire page -
shop module, product controller. links have additional param called item, name of product. when click on link, either never generates want url or page doesn't show.
i've tried several ways.
'shop/product/view/<id:\d+>/<item:\w+>'=>'<item>',
gives me shop/product/view/6?item=name
'<module:(shop)>/<controller:(product)>/<action:(view)>/<id:\d+>/<item:\w+>'=>'<item:\w+>'
gives me same above
shop/product/view/id/<id:\d+>/item/<item:\w+>'>=>'shop/<item:\w+>'
, gives me error page unable resolve request "shop/name"
.
i've attempted write own extending curlmanager failed. gives me same url.shop/product/view/6?item=name
class urlmanager extends curlmanager { public $connectionid = 'db'; public function createurl($manager,$route,$params,$ampersand) { if ($route == 'shop/product/view'){ $product = product::model()->findbypk($params['id']); $url=$product->product_name; homecoming yii::app()->createurl(trim($url,'+'),$params,$ampersand); }
update:
'urlmanager'=>array( 'urlformat'=>'path', 'showscriptname'=>false, 'rules'=>array( 'shop/product/view/id/<id:\d+>/item/<item:\w+>'=>'<item>', //'category'=>array('site/category', 'casesensitive'=>false), //'shop'=>array('shop/product/view','casesensitive'=>false), //'<module:\w+>/<controller:\w+>/<action:\w+>/<id:\d+>'=>'<module>/<controller>/<action>', //'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>', // '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', // 'reset/<id:\d+>/<item:\w+>'=>array('site/reset/id', 'casesensitive'=>false), ), ),
shop/<item:\w+>
looks identical controller/action believe gets overwritten other rules have. can post rules see them all?
also seek putting rule in origin of rules array, should create have priority on other rules.
yii yii-url-manager
No comments:
Post a Comment