in the new Yii Custom Url Class
config
array(
// a standard rule mapping '/' to 'site/index' action
'' => 'site/index',
// a standard rule mapping '/login' to 'site/login', and so on
'<action:(login|logout|about)>' => 'site/<action>',
// a custom rule to handle '/Manufacturer/Model'
array(
'class' => 'application.components.CarUrlRule',
'connectionID' => 'db',
),
// a standard rule to handle 'post/update' and so on
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
class
public function parseUrl($manager,$request,$pathInfo,$rawPathInfo)
{
if (preg_match('%^(\w+)(/(\w+))?$%', $pathInfo, $matches))
{
// check $matches[1] and $matches[3] to see
// if they match a manufacturer and a model in the database
// If so, set $_GET['manufacturer'] and/or $_GET['model']
// and return 'car/index'
}
return false; // this rule does not apply
}
Where do I check for the url pattern of my custom rule?
in my old question it did it easily like this
'product/<category:[\d\w-\/]+>'=>array( // used by EDbUrlManager
'product/viewCategory',
'type'=>'db',
......
With the new 1.1.8 new custom rule class i tried many
if (preg_match(’%^[\d\w-\/]+?$%’, $pathInfo, $matches))
if (preg_match(’[\d\w-\/]+’, $pathInfo, $matches))
if (preg_match(‘product/<category:[\d\w-\/]+>’, $pathInfo, $matches))
and obviously my regex sucks as idk what I am doing…
I need a help to construct a regex pattern that match "product/cat1/cat2/cat3…cat100…cat200" that will work with the new custom rule.