0

Is it possible to define a custom URL for CakePHP pagination url?

I need something like /:slug/:slug2/:slug3/. How should I provide this url to pagination?

Thanks!!

P.S. If I'm using this, CakePHP defines controller and view automatically in the URL and result is /controller/action/something/ - I need to disable controller and action in url.

$this->Paginator->options(array(
    'url' => '/something/'
));

2 Answers 2

2

Use routing. http://book.cakephp.org/2.0/en/development/routing.html

You should not use string type URLs for "internal" links because they won't work the routing and your links wont work any more in the case the app is in subdirectory of the webroot.

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

6 Comments

I don't think you understand: Routing maps the array to whatever your routing rule is string type URL and vice versa. Read the link before saying something does not work or is wrong. Routing is the tool for SEO as it allows you to generate whatever URL you want.
The problem is, CakePHP doesn't let the [/catalog/*/] routing, if there is url /catalog/something - this route accepts it, but it shouldn't, because there is no slash in the end. So it is not possible to make routes for links like /catalog/:slug/* in CakePHP - the star catches all deeper slugs in the first route.
That's simply plain wrong as I've implemented this multiple times. It is a matter of the order of the routes. So what have you tried...?
for me, route [/catalog/*/] catches everything: /catalog/smth And /catalog/slug/ And /catalog/slug/slug2/... links
You don't understand how routing works. As I said it goes by priority and the star is a wildcard. You have to define a route like /:slug1/:slug2/:slug3/ and very likely create your own route class to check if that's a valid route. And put it BEFORE your /catalog/* rule. If it fails to match your /catalog/* is the next one that will try to match.
|
2

in your view:

$this->Paginator->options(array('url' => $this->passedArgs));

Will add arguments passed to your pagination links.

1 Comment

This just adds more stuff to the URL; it does not replace or remove the default controller/action from the pagination URL, as the OP requested

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.