Yii Framework Forum: URL manager rules problem - Yii Framework Forum

Jump to content

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

URL manager rules problem Rate Topic: -----

#1 User is offline   jeph 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 05-February 10

Posted 02 June 2010 - 11:57 AM

I've got many rules on my url manager and sometimes the proper page to be displayed does not show. Then if I rearrange the rules and assign it as the first rule it works out perfectly then another rule does not work. What could be affecting this?
0

#2 User is offline   andy_s 

  • Random Member Title
  • Yii
  • Group: Moderators
  • Posts: 1,526
  • Joined: 22-June 09
  • Location:Russia, Kostroma

Posted 02 June 2010 - 12:14 PM

Will be good to see your rules.
The order of url rules is important sometimes. Just for example:

'foo/<bar:.*>'=>'controller/action1',
'foo/<bar:\d+>'=>'controller/action2',

The second rule will never work.
0

#3 User is offline   jeph 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 05-February 10

Posted 02 June 2010 - 12:21 PM

I see, that must be the problem. My arrangement is really messed up. I just added rules everywhere. Could you give me some tips on how to properly place the rules. Thanks for the help.
'rules'=>array(
                'ads/post'=>'bsAds/newitem',
                'ads/<type>/<prop>/<city>/<loc>'=>'bsAds/list',
                'ads/<type>/<prop>/<city>'=>'bsAds/list',
                'ads/<type>/<prop>'=>'bsAds/list',
                'ads/<type>'=>'bsAds/list',           
                'user/step1'=>'userInfo/step1',
                'user/step2'=>'userInfo/step2',
                'user/step3'=>'userInfo/step3',
                '<type>/<user>'=>'userInfo/show',                
                'u/<user>'=>'userInfo/show',                
                'ads/<cat>/property/<prop>'=>'bsAds/list',
                'ads/<cat>/make/<make>'=>'bsAds/list',
                'ads/<cat>/location/<loc>'=>'bsAds/list',          
                '<id>/<pagetitle>' => 'bsOtherpages/show',                
                'partners'=>'bsPartners/list',
                'partners/apply'=>'bsPartners/create',
                'logout'=>'site/logout',
                'alerts'=>'bsAlerts/create',
                'bookmarks'=>'userBookmark/list',
                'login'=>'site/login',
                'forum'=>'forumInfo/list',
                'forum/<name>'=>'forumTopic/list',
                'forum/<name>/post'=>'forumTopic/create',
                'forum/view/<topicid>'=>'forumPost/list',
                'forum/<topicid>/reply'=>'forumPost/create',
                'groups'=>'userGroup/list',
                'ads/tags/<tag>'=>'bsAds/list',
                'ads/date/<date>'=>'bsAds/list',                
                'ads'=>'bsAds/list',
                'search/<term>'=>'bsAds/search',
                '<cat>'=>'bsAds/list',
                'ads/<id>/<type>/<prop>/<city>/<loc>/<title>'=>'bsAds/show',
                'ads/<id>/<make>/<model>/<type>/<title>'=>'bsAds/show',
                'ads/<id>/<loc>/<prop>/<type>/<title>'=>'bsAds/show',
                'ads/<id>/<make>/<type>/<model>/<title>'=>'bsAds/show',
                'auto/<id>/<make>/<model>/<type>/<title>'=>'auto/show',
                'mobile/<id>/<type>/<title>'=>'mobile/show',
                'realty/<id>/<type>/<title>'=>'realty/show',
           ),
 

0

#4 User is offline   andy_s 

  • Random Member Title
  • Yii
  • Group: Moderators
  • Posts: 1,526
  • Joined: 22-June 09
  • Location:Russia, Kostroma

Posted 02 June 2010 - 12:33 PM

From your rules:

'ads/<id>/<make>/<model>/<type>/<title>'=>'bsAds/show',
'ads/<id>/<loc>/<prop>/<type>/<title>'=>'bsAds/show',


How will Yii guess which rule to choose, if it will be "ads/15/abc/def/ghi/jkl" ? You should specify the range for params. For example, <make> can be only "foo" or "bar". Or maybe it should be a number: <loc:\d+>.
0

#5 User is offline   jeph 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 05-February 10

Posted 02 June 2010 - 01:32 PM

Thank you very much I think I got it. I just need to help yii to recognize that each rule is different.
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