How to serve static pages with Zend Framework

We are currently using the Zend Framework and the MVC template on our website. We have a large number of static pages that are located in random areas of the site. These pages are not simple HTML pages that can bypass ZF at all ... they will participate in Zend_Layout, etc.

What is the best way to serve these pages without creating a separate action / controller for each random page? Repeating page layout so that they all fall under a β€œdifferent” controller or something is missing, the pages should stay where they are in our hierarchy of URLs for SEO purposes.

+6
zend-framework-mvc
source share
1 answer

If I understand the question correctly:

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

Zend actually separates the URL from $ controller-> action (), so it happens that the default value for this is used for the Zend MVC part. You can still create a misc controller that gets any random URL, you just need to define some custom routes.

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

Zend Framework site citation example:

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

Above the route will be the URL http://domain.com/login , and sending to AuthController :: loginAction ().

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

+6
source share

All Articles