开发者

CakePHP 2.0 RSS error (doesn't parse extension)

开发者 https://www.devze.com 2023-04-05 02:40 出处:网络
I\'m migrating one of my website from cake 1.3 to 2开发者_如何学运维.0 rc1 and I have a problem with my rss feed.

I'm migrating one of my website from cake 1.3 to 2开发者_如何学运维.0 rc1 and I have a problem with my rss feed.

When I call my feed with something like mydomain.com/mycontroller/index.rss I have an error :

Error: The action index.rss is not defined in controller MycontrollerController

Error: Create MycontrollerController::index.rss() in file: app/Controller/MycontrollerController.php.

<?php
class MycontrollerController extends AppController {
    function index.rss {

    }
}
...
?>

I didn't change anything since 1.3 (and rss were working), and I have the parseExtensions in my routes.php :

Router::parseExtensions('rss', 'xml');

I found nothing about it in the doc and google :(

Thanks a lot !


The action in your controller shouldn't be named index.rss.

You should verify a few things:

• Are both the TextHelper and RequestHandlerComponent called in your controller? • Have you created an index action with the following code?

if ($this->RequestHandler->isRss() ){
    $posts = $this->YourModel->find('all', array('limit' => 20, 'order' => 'Post.created DESC'));
    return $this->set(compact('posts'));
}

• Verify you have created a default.ctp in /View/Layouts/rss/

• Do the same for the RSS view in /View/YOUR_CONTROLLER/rss/index.ctp

Also, see the manual entry in the Cake documentation.

If that doesn't solve the issue it could be related to URL rewriting with mod_rewrite. Do you have any other problems with URLs not being found?

0

精彩评论

暂无评论...
验证码 换一张
取 消