Yii Framework Forum: CUrlManager splitted to 2 classes - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CUrlManager splitted to 2 classes to allow 2 differents rules arrays Rate Topic: -----

#1 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 244
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 12 May 2012 - 03:54 AM

Hi,
When we try to extract an ID from an url-friendly ID (example: /post/32-do-you-like-bananas) we will use :
'rules' => array(
'<controller:\w+>/<id:\d+>\-.+' => '<controller>/<id>',


CUrlManager will extract '32' as $id in :
public function actionPost($id) {
echo $id; // outputs 32
}

but in the same time, it will also create urls like :
localhost/post/32-do-you-like-bananas\-.+

That's why i think Yii should enable 2 separated rules arrays.
One will be used for createUrl() and another one for parseUrl()
And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
0

#2 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 244
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 13 May 2012 - 07:48 AM

oops,
it was my rules syntax
i solved the problem
And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
0

#3 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,317
  • Joined: 12-October 09
  • Location:Croatia

Posted 13 May 2012 - 08:44 AM

Would be nice if you can write here the rigth rule syntax... this would help if someone in the future comes to this thread with a similar problem.
Find more about me.... btw. Do you know your WAN IP?
0

#4 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 244
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 13 May 2012 - 03:13 PM

Here is a portion of code that worked fine with the default URL manager:

        'urlManager'=>array(
            'urlFormat'=>'path',
            'showScriptName'=>false,
            'rules'=>array(
                '<controller:\w+>/<action:page>/<view:.+>'=>'<controller>/<action>',
                '<controller:\w+>/<action:\w+>/<id:\d+>/<title:.+>'=>'<controller>/<action>',
                '<controller:\w+>/<id:\d+>/<title:.+>'=>'<controller>',
                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
            ),
        ),


Assuming you are creating URLs like :
$this->createUrl('products/details',array('id'=>$data->id,'title'=>$data->title));

And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users