Hi,
my pagination links look like this:
http://localhost/controllerName/actionName?page=2&cat_id=1®_id=1
What can I do to get a more seo friendly naming?
For example like:
http://localhost/categoryName/regionName?page=2&cat_id=1®_id=1
What I already got is to modfiy the search form via jQuery to change the form action depending on the search - so I land already on the search results page with this url looking like
localhost/categoryName/regionName
I just need “to tell pagination” to use the URL and just add the vars.
What can I do to get this?
Thanks!!
You’ll need to setup the correct routes. Take a look at https://book.cakephp.org/3.0/en/development/routing.html#routes-configuration
Once that is done, the CakePHP router should take care of everything for you.
1 Like
Hi dakota. Yes I already tried but I can’t find a proper solution for this. Or in other words, I don’t know what exactly to look for on my specific case. Would it be possible to get some specific help from you?
Whats the exact controllers, etc. that you have? I can only try to help if I know the real names you are using 
Hi dakota,
http://localhost/objekts/search?page=4&cat_id=1
controller = objekts
action = search
thanks so much!!
Hey heohni,
you should define a Route in the routes.php for your needs like:
Router::connect(
'/my-custom-rote/whatever-i-want/:id/:slug/:etc',
['plugin' => 'MyPlugin', 'controller' => 'TheController', 'action' => 'TheAction']
);
Its very simple - or read the docs https://book.cakephp.org/3.0/en/development/routing.html#quick-tour
So, you want http://localhost/objekts/search?page=4&cat_id=1
?
What I have by cake default is this:
localhost/objekts/search?page=4&cat_id=1
What I want is that the pagination number links point to
localhost/myCustomName/myCustomName2?page=4&cat_id=1®_id=1
in case I have reg_id and cat_id
or
localhost/myCustomName?page=4&cat_id=1
in case I have only cat_id
Let me define this:
When using this (thanks MarksSoftware)
Router::connect(‘/this-is-my-special-name?cat_id=:cat_id’,
[‘controller’ => ‘objekts’, ‘action’ => ‘search’]
);
my links look like:
On page:
localhost/Apartments (this is shown in the browsers address bar)
the pagination number links look now like
localhost/this-is-my-special-name?cat_id=1?page=2
so far - we getting closer.
What can I do now that route takes the part “Apartments” from the address bar?
To get a link like
localhost/Apartments?cat_id=1?page=2