views:

218

answers:

1

Hello guys,

I've been trying to figure this out these days. I got a problem when I want to add 'page' parameter in my URL for my pagination.

This is my router


        ->addRoute('budi',new Zend_Controller_Router_Route(':lang/budi',array('controller' => 'budi', 'action' => 'index', 'page' => 1), array('lang'=>$s, 'page' => '\d+')))
        ->addRoute('budi1',new Zend_Controller_Router_Route(':lang/budi/page/:page',array('controller' => 'budi', 'action' => 'index', 'page' => 1), array('lang'=>$s, 'page' => '\d+')))

Then I access my URL


http://localhost/learningsystem/en/budi

but when I hover on my pagination links, the page parameter doesn't appear. The URL is still http://localhost/learningsystem/en/budi

but if I enter same URL with index in the end like this one


http://localhost/learningsystem/en/budi/index

or like this one


http://localhost/learningsystem/en/budi/page/1

the page parameter appears perfectly when I click the page 2 link http://localhost/learningsystem/en/budi/index/page/2

Actually, I don't want include 'index' or 'page' at first in my URL. Anyway, I use default pagination.phtml template from Zend. Anyone please help me to solve this problem?

Thank you very much

A: 

How about something like these?

$router->addRoute(
  'budi',
  new Zend_Controller_Router_Route_Regex(
    '(.*)/budi',
    array('controller' => 'budi', 'action' => 'index', 'page' => 1),
    array(1 => 'lang', 2 => 'page'),
    '%s/budi/page/%d'
  )
);
$router->addRoute(
  'budi1',
  new Zend_Controller_Router_Route_Regex(
    '(.*)/budi/page/(\d*)',
    array('controller' => 'budi', 'action' => 'index'),
    array(1=>'lang', 2=>'page'),
    '%s/budi/page/%d'
  )
);
Derek Illchuk