I posted once of custom URLs within Zend Framework, but back than I wasn’t quite sure enough there isn’t a better, more elegant way to do this job. Of course as it appears, there is! With no need to is to use the power of regular expressions with Zend_Controller_Router_Route_Regex. Thus you can match dynamically the URL.
Let’s assume you’d like to have a link with something like www.example.com/3939-some-title-here. This is really very common. So to proceed you’d have to have some regex like:
$pattern = '/\d+-.*/; |
So what about Zend Framework
Here the things are going naturally more OOP.
$route = new Zend_Controller_Router_Route_Regex('(\d+)-?(.*)', array('controller' => 'controller_name', 'action' => 'action_name'), array(1 => 'id')); $ctrl->addRoute('my-route', $route); |
where you get and asign value for this ‘some-title-here’ in this example? From router know the title value for selected page? this tutorial not explain anythink