I've just come across[1] a neat way to deal with static pages over at
CakeBaker's site. It's an improvement (imho) on Jonathan Snook's
version[2] (which is also pretty neat). Though I'm leaning towards
moving to this method, I'd really like to figure something out.

I've had a system for serving static pages for a while now that's
worked out really well. I can have arbitrarily-nested dirs of static
pages without any problems. But there are two issues, one a minor
inconvenience, the other quite frustrating.

1) I need to specify (almost) all of the routes manually:

Router::connect('/contact', array('controller' => 'pages', 'action' =>
'display', 'contact'));
Router::connect('/links', array('controller' => 'pages', 'action' =>
'display', 'links'));
Router::connect('/sitemap', array('controller' => 'pages', 'action' =>
'display', 'sitemap'));
Router::connect('/about', array('controller' => 'pages', 'action' =>
'display', 'about/index'));
Router::connect('/about/*', array('controller' => 'pages', 'action' =>
'display', 'about'));

That last one will catch any requests for stuff inside the
"views/pages/about" dir, while its predecessor will serve up the
"/about/index" page. I'm not at all whining about this. I'm fine with
it, as I don't have very many static pages. YMMV.


2) I can't use Cake's super-fantastic reverse-routing arrays to create
links without having "pages" tag along for the ride. Using the first
route, above, as an example, if I create a link like this:

$html->link(
        'Contact',
        array('controller' => 'pages', 'action' => 'display', 'contact'),
        array('title' => 'How to contact us')
)

.. I get "/pages/contact". But I can use custom routes for other controllers:

Router::connect('/foobar', array('controller' => 'newsletters',
'action' => 'index'));

$html->link(
        'click here',
        array('controller' => 'newsletters', 'action' => 'index')
)

gives: "/foobar", which calls up my NewslettersController::index() action.

So, where the difference? In going through the source, I've gotten as
far as Router::connectNamed() but am stumped as to what's going on.
How/why is this happening?

More importantly, does anyone have any suggestions for overriding this
feature? Preferably without goofing around inside cake/libs, of
course, though I'd be willing to do it for this.


[1] http://snook.ca/archives/cakephp/static_pages_cakephp12/
and
http://snook.ca/archives/cakephp/easier_static_pages_2/

[2] 
http://cakebaker.42dh.com/2008/06/18/an-alternative-approach-for-static-pages/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to