1

I am new to Zend Framework. I have a page that is:

http://localhost/demo/public/index/index/catid/art

I want to change that into

http://localhost/demo/public/art

I have no idea how to do it.

Also, why does it put index twice? Even my pagination has it, like:

http://localhost/demo/public/index/index/page/2

In my opinion is a little bit annoying. I would like the pagination to be

http://localhost/demo/public/page/2

Is there a way to do that? Thanks!

1
  • Did you really need to confuse your question by having "/demo/demo/public/" prefixed in every URL? I had to assume that your baseURL started from /demo/demo/public/. Commented Oct 25, 2012 at 17:32

1 Answer 1

2

The default route works by using:

/module/controller/action

So if you have a module called "default", and your controller called "index", and an action called "index", then the most verbose way to refer to that specific action would be:

/module/controller/action

In order to set up a route you would use:

$route = new Zend_Controller_Router_Route(
           'page/:page',
           array(
              'module' => 'default'
              'controller' => 'index',
              'action' => 'index'
            ),
            array(
               'page' => '\d+'
             )
          );

You could then get the page param in your controller using

$this->getRequest->getParam("page");

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

2 Comments

it worked like a charm for the pagination. How can I do it for the first example? to hide the parameter?
You can figure this one out. :) I helped you on the more difficult example. Find framework.zend.com/manual/1.12/en/…

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.