Hello All,
Please help me to configure CUrlManager for flexibility
How can I set rules to use URL like this:
or any idea to create own UrlRule class to parseUrl() and createUrl()
I have create a UrlRule class:
class VUrlRule extends CBaseUrlRule {
public function createUrl($manager, $route, $params, $ampersand) {
return $route;
}
public function parseUrl($manager, $request, $pathInfo, $rawPathInfo) {
$pathInfo = preg_replace("%(\-)%", "_", $pathInfo);
return $pathInfo;
}
}
and have added to config/main.php as
'urlManager' => array(
'urlFormat' => 'path',
'rules' => array(
array(
'class' => 'application.components.VUrlRule',
),
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
),
After adding this all request are working
But when I’m getting parameter to action method it throws error 500
public function actionAnother_Category($id) {
// This method is not working because one parameter is used
// When removes $id from parameter it works
}