i want do a rss, I followed this http://book.cakephp.org/3.0/en/views/helpers/rss.html. But the things not working correctly, because when access the router of the rss, it returns a controller error, saying that controller does not exists. My route is this:
/posts/index.rss
When do this request, it return a error of the controller not found.
The action index.rss is not defined in PostsController
I declared that "app" to accepts rss..My complete config/routes.php
use Cake\Core\Plugin;
use Cake\Routing\Router;
Router::defaultRouteClass('Route');
Router::scope('/', function ($routes) {
Router::extensions(['json', 'xml', 'rss']);
$routes->connect('/', ['controller' => 'Fronts', 'action' => 'index']);
$routes->connect('/contact', ['controller' => 'Fronts', 'action' => 'contact']);
$routes->connect(
'/:controller/:action/:id-:slug',
[],
[
'pass' => ['id', 'slug'],
'id' => '[0-9]+',
'routeClass' => 'DashedRoute'
]
);
$routes->fallbacks('InflectedRoute');
});
Plugin::routes();
I also made the LoadComponent in :: initialize () of the controller
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
}
And my controller
class PostsController extends AppController
{
...
public function index()
{
...
if($this->RequestHandler->isRss()) :
$_rss = $this->Posts->find()->limit(20);
$this->set(compact('_rss'));
return;
endif;
...
}
}
Whats is wrong?
Thankss..!!!
/plosts/index.rss? shouldn't it be/post/index.rss? - Oops D'ohRouter::extensions('rss');in/config/routes.php? Any other error messages in/logs/? Did you create a view file insrc/Template/Posts/rss/index.ctp? - Oops D'oh