I think one other solution to this would be to add some custom routes to your router.

Remember when you add these that they are processed in LIFO order. This caught me out previously.

$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();

|$router->addRoute('|catalog', new Zend_Controller_Router_Route('catalog/page/:page', array('module' => 'default', 'controller' => 'catalog', 'action' => 'index'))); |$router->addRoute('|manufacturer', new Zend_Controller_Router_Route('catalog/:manufacturer/page/:page', array('module' => 'default', 'controller' => 'catalog', 'action' => 'index'))); |$router->addRoute('|model', new Zend_Controller_Router_Route('catalog/:manufacturer/:model/page/:page', array('module' => 'default', 'controller' => 'catalog', 'action' => 'index'))); |$router->addRoute('|year', new Zend_Controller_Router_Route('catalog/:manufacturer/:model/:year/page/:page', array('module' =>'default', 'controller' => 'catalog', 'action' => 'index')));



I whant to have links like this:
/catalog/[audi]/[rs8]/[2006]/page/3

[audi] [rs8] and [2006] are optional parametrs so my links should work if
I access them like this:
/catalog/page/23
/catalog/audi/page/21
/catalog/audi/rs8/
/catalog/audi/rs8/2008/page/1





Eduard Bareev wrote:
I am newbie too, and i think if i write some wrong advice, a more skilled
zf'ers can correct me.

I think one of the way to realize this friendly URLs as you want is to
create custom router.
This can be done by implementing Zend_Controller_Router_Route_Interface. Shortly, in general it consist of one method: match($path), which must
return an array with pair of desided controller and action in case of it
mathed to tested url, and false otherwise.

    class PartsSearchRouter implements
Zend_Controller_Router_Route_Interface{
        /* ... */
        public function match($path){
             $newPair['controller'] = 'PartsCatalogSearch';
             $newPair['action'] = 'filterByModel';
        }
        /* ... */
    }

But probably it would be necessary to test every occurred parsed term (like
'audi' or 'rs8') in passed url to correspondence to any existing car maker
or model in your database, to determine what this term is mean, and
determine what the url scheme is actually occurred. And because this may be
very resource expensive operation, maybe is reasonable to implement some
caсhe in future.


Irmantas wrote:
Hi, my English is not very good so I excuse for my mistakes.

I whant to have links like this:
/catalog/[audi]/[rs8]/[2006]/page/3

[audi] [rs8] and [2006] are optional parametrs so my links should work if
I access them like this:
/catalog/page/23
/catalog/audi/page/21
/catalog/audi/rs8/
/catalog/audi/rs8/2008/page/1

Does any body may help me to find solution?


Reply via email to