Friday, December 26, 2014

Problem with creating routes

I have a simple project that I'm trying to convert to a CakePHP project: http://optiekcardoen.be/home
The page navigation is very simple:

- Home (/)
- Shop (/shop)
- Products (/products)
    - Frames (/products/frames)
    - Sunglasses (/products/sunglasses)
    - Lenses (/products/lenses)
    - Hearing aids (/products/hearing-aids)
    - Glass (/products/glass)
    - Optometry (/products/optometry)
- Discounts (/discounts)
- Facts (/facts)
- Fotoshoots (/fotoshoots)
- Contact (/contact)

This is my current .htaccess file where I do the routing:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /


RewriteRule ^home$ index.php
RewriteRule ^producten/([^/\.]+)$ $1.php
RewriteRule ^([^/\.]+)$ $1.php

In CakePHP, routing should happen in app/Config/routes.php. Here's my attempt to fit the current routing in the CakePHP routing:

Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::connect('/*', array('controller' => 'pages', 'action' => 'display'));
Router::connect('/producten/:product-type',
 array
('controller' => 'pages', 'action' => 'display'),
 array
('pass' => array('product-type'))
);

Unfortunately, I get errors when I try to reach the product detail pages (e.g. /products/frames):

Missing View
Error: The view for PagesController::display() was not found.
Error: Confirm you have created the file: D:\Websites\Optiek Cardoen\05 - Cake\app\View\Pages\producten\monturen.ctp
Notice: If you want to customize this error message, create app\View\Errors\missing_view.ctp

It says that the last rule in routes.php isn't correct, but how can I make it work to fill my needs?
Thanks in advance!

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: