urlmanager and xhr request unreachable

Hi folks!

Got an issue with the urlmanager and ajax request. Let me explain in few words.

I have the following rules set up:


        'urlManager'=>array(

            'showScriptName'=>false,

            'urlFormat'=>'path',

            'urlSuffix' => '.html',

            'rules'=>array(

                'contact' => 'site/contact',

                'blog' => 'blog/index',

                'blog/<url>' => 'blog/read',

                'formations' => 'site/formations',

                'accueil' => 'site/index',

                'apropos' => 'site/aPropos',

            ),

      ),

And an action defined in my blog controller as follow:


public function actionXhrFilterEntries()

{

...

}



But once I set up the rules for the blog the action xhrFilterEntries is not reachable anymore via a browser, so you guys have any ideas why? Racking my brain about that but cant find any solution :confused:

Cheers

sorry about multiple mesages, I got a SQL error when trying to post my message :confused: could someone delete the others posts please? thanks

Maybe missing the .html suffix in your request URL?

hum I am passing the URL to the JS with the method $this->createUrl() :confused:

I really dont see why it doesnt work, but the strange thing is that even after having this rules set up for the blog the xhrFilterEntries() method is not reachable via the browser with the following link:

http://www.blabla.com/blog/xhrFilterEntries.html

I do not see how blog controller cand get to that action in the first place. Should not include one like this?

‘<blog>/<action:\w+>.html’=>’<blog>/<action>’,

Looks like I fixed it by doing:


            'rules'=>array(

                'contact' => 'site/contact',

                'formations' => 'site/formations',

                'accueil' => 'site/index',

                'apropos' => 'site/aPropos',

                'blog' => 'blog/index',

                'blog/xhrFilterEntries.html' => 'blog/xhrFilterEntries',

                'blog/<url>' => 'blog/read',

            ),

Weird, as if do not put the ‘blog/xhrFilterEntries.html’ => ‘blog/xhrFilterEntries’, rule it doesnt work.

Why so? Anyone could tell me the reason please?

Thanks.

if you don’t include your rule in matching the URL it wont work at all and will display a 404 error (not found). In your rules there is no way to tell Yii to redirect to controller/action.

By including ‘blog/xhrFilterEntries.html’=>‘blog/xhrFilterEntries’ you are saying to Yii that if there is a match of blog/xhrFilterEntries.html to call blog controller and its xhrFilterEntries action, and if you do createUrl(‘blog/xhrFilterEntries’) will be converted to blog/xhrFilterEntries.html.

"when using createUrl to generate a URL, the route and the GET parameters passed to the method are used to decide which URL rule to be applied. If every parameter associated with a rule can be found in the GET parameters passed to createUrl, and if the route of the rule also matches the route parameter, the rule will be used to generate the URL."

This is the way I understand it.