0

I have no idea how realize it.

I have this router

$route = new Zend_Controller_Router_Route_Regex(
                    'category/([-\w]+)(?:/(\d+))?',
                    array('module' => 'dynamic', 'controller' => 'index', 'action' => 'show-category'),
                    array(1 => 'category', 2 => 'pageNumber'),
                    'category/%s/%d'
    );

$router->addRoute('dynamic-categories', $route);

Assembled url in view will be /category/news/1 by using $this->url(...) helper. I want that my first page of news will be /category/news. Should I use other route to do it or use router chaining. I'm frustrated. Thank you for help.

1 Answer 1

1

You can use Zend_Controller_Router_Route for straight forward mapping:

new Zend_Controller_Router_Route(
    '/category/:category/:page',
    array(
        'module' => 'dynamic',
        'controller' => 'index',
        'action' => 'show-category',
        'category' => 'news',
        'page' => 1   
    )
)

Will match /category/, /category/news/, /category/othercategory or /category/news/4 (examples only of course).

Sign up to request clarification or add additional context in comments.

1 Comment

category may be news, articles, posts, etc. Should I write this route rule for each category?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.