Hello Everyone…I am trying to clear my default url into own url. For which I have created slug column name in my table for which
http://decontrader/index.php?r=product/show&id=1422 and I am trying to convert this url into
http://decontrader/index.php/product/slug.
and I have added
'product/<slug:[a-zA-Z0-9-]+>'=>'product/view', in the url manager at config/main.php and similar I have followed such code in the respective controller
public function actionView($slug)
{
$this->render('view',array(
'model'=>$this->loadModelSlug($slug),
));
}
public function loadModelSlug($slug)
{
$model = Product::model()->findByAttributes(array('slug'=>$slug));
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
. Now my problem is when the slug is in following format with hyphen like slug-word it supports. but when slug is single word it does not show the view. I wondering if any can help me out.
Thanks in Advance
Regards
Sundar