1

I'm building a Zend Framework sites. It's MVC, so uses controllers so I have controllers like NewsController that is accessed via /news etc. However, another of my controllers is PagesController, which handles just static content pages.

My PagesController is also my default controller. So http://example/ returns PagesController::home(). I also have a method called view() that takes $slug as a parameter.

What I'd like to do is set up a route whereby if I request http://example.com/about and there isn't a NewsController, that the request is passed to the view() method of my PagesController.

I'm a Zend Framework n00b so have no idea where to start with this. Is this possible? If so, how could I achieve this?

Martin Bean
  • 38,379
  • 25
  • 128
  • 201
  • When you say "there isn't a NewsController" do you mean news controller can't handle it or there's no physical file NewsController.php present? – Weltschmerz Mar 27 '12 at 14:43
  • I just mean by Zend Framework's default routing. So if I requested **/news**, then it would look for `NewsController`. Basically, if the default routes all miss, I then want the request passed to my `PagesController` to try and find a content page in the database, and if there isn't one there to throw the normal 404 error page. – Martin Bean Mar 27 '12 at 15:13

1 Answers1

1

I have answered this before on Zend Framework website.com/username by using a plugin. In that plugin, you can just replace $username with your slug and change the request params as needed.

Community
  • 1
  • 1
brady.vitrano
  • 2,256
  • 2
  • 16
  • 26