views:

840

answers:

2

We currently employ Zend Framework and the MVC pattern on our website. We have large numbers of static pages, which are in random areas of the site. These pages are not simple HTML pages that can bypass ZF altogether... they would participate in the Zend_Layout, etc.

What is the best way to serve these pages without creating a separate action/controller for each random page? Redoing the layout of the pages so that they all fall under a "misc" controller or something is not an option, the pages need to stay where they are in our URL hierarchy for SEO purposes.

+2  A: 

If I understand the question properly:

  • You have a bunch of static content you would like to apply your layout to.
  • These pages of static content already have existing urls you don't want to break

Zend actually separates URL from $controller->action(), it just so happens the MVC part of Zend has a default setting to do this. You can still create a "misc" controller which receives any random url, you just need to define some custom routes.

http://framework.zend.com/manual/en/zend.controller.router.html

quoting example Zend Framework site:

$route = new Zend_Controller_Router_Route_Static(
    'login',
    array('controller' => 'auth', 'action' => 'login')
);
$router->addRoute('login', $route);

Above route will match a URL of http://domain.com/login, and dispatch to AuthController::loginAction().

More ambitious examples using pattern matching can be found on the same page.

TK
A: 

John -- did you ever find an elegant solution to this issue? Am looking for a nice way to do the same. thanks!

Marc