1
votes

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?

1
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
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

1 Answers

1
votes

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.