Yii Framework Forum: Invalid CUrlManager matching - Yii Framework Forum

Jump to content

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

Invalid CUrlManager matching Rate Topic: -----

#1 User is offline   slyder 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 14-May 09
  • Location:Russia

Posted 06 July 2010 - 03:20 PM

Hello,
I have next rules for CUrlManager:

            'rules' => array(
1:                //'estate/viewQuickInfo/id/<id:\d+>' => array('estate/viewQuickInfo'),
2:                '<estateTypeUrlTitle>/<cityUrlTitle>/<title>/<id:\d+>' => array('estate/view'),
3:                'estate/<title>/<id:\d+>' => 'estate/view',
            ) 



As i understood second rule should manage only urls with estateTypeUrlTitle, cityUrlTitle params:

    <?php echo CHtml::link(
        $data->getCaption(), array(
            '/estate/view',
            'estateTypeUrlTitle' => $data->type->urlTitle,
            'cityUrlTitle' => $data->city->urlTitle,
            'id' => $data->id,
            'title' => $data->urlTitle,
        ), array('class' => 'location'));
    ?>


but current rules also manage any link with id. For example:

http://heat.in/estat...uickInfo/id/305
http://heat.in/estate/delete/id/305
http://heat.in/anyco...nyaction/id/305 !!!!!!!!!!

show same page, like http://heat.in/estate/view/id/305.

Then i uncomment rule 1 i have valid result for
http://heat.in/estat...uickInfo/id/305 link, but i think it is invalid to add rule for each other controllers/action just so they will retain work?

Is it possible to do so second rule works only for URLs with estateTypeUrlTitle, cityUrlTitle params?

Konstantin
0

#2 User is offline   BornToDrink 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 31-December 09
  • Location:Bulgaria

Posted 09 July 2010 - 06:40 AM

Hi slyder,

in you have this rule:
'<estateTypeUrlTitle>/<cityUrlTitle>/<title>/<id:\d+>' => array('estate/view'),

and url like:
site.com/string1/string2/string3/someINT
This means, that always controller Estate and action View will be requested.
If you just need to call controller/action/id/5, you don't need rules.
Just set urlFormat to path, showScriptName to false and CUrlManager will do the rest.
site.com/estate/delete/id/5
Will call controller Estate, action Delete with get parameter ID = 5.
For this kind of URLs, rules are not needed.

If you want some custom URLs, like:
site.com/contacts
so then you need this rule:
'contacts' => 'site/contact', //controller Site, action Contact

And
CHtml::link('Contacts', array('site/contacts'));

or another example:
'contacts/<title>' => 'site/contact', //controller Site, action Contact

and
CHtml::link('Contacts', array('site/contacts', 'title' => 'Sales'));

This will output:
site.com/contacts/Sales
And in controller site, action contacts you will know, that contact form should be for Sales team ($_GET['title'] == 'Sales')...
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