I looked around to find answers and though I found topics about the routes, none of the answers I found worked in this case. So here I go, trying to explain my problem =]
Background information
I'm making a website in Cakephp for an estate agent. On this website you have the possibility to sort houses based on the street, publish date and price.
What I want
I want to change these current urls:
websitename.nl/houses/index/page:4/sort:street/direction:desc
websitename.nl/houses/index/sort:street/direction:desc/page:4
to something like:
websitename.nl/houses/street/descending/4
websitename.nl/houses/price/ascending/4
Street/price and descending/ascending will be translated to dutch.
What I already tried
I tried to add this in routes.php:
Router::connect('/huizenaanbod/datum/aflopend/:page', array('controller' => 'houses', 'action' => 'index', 'sort'=>'published', 'direction' => 'desc'), array('page' => '[0-9]+'));
Router::connect('/huizenaanbod/datum/oplopend/:page', array('controller' => 'houses', 'action' => 'index', 'sort'=>'published', 'direction' => 'asc'), array('page' => '[0-9]+'));
But it ignored the desc and only the asc worked.. So I tried to add this at the index.ctp:
if((!empty($this->params['sort']) && $this->params['sort'] == "published") && $this->params['direction'] == 'desc'){
echo $this->Paginator->sort('published', 'datum', array('direction' => 'asc', 'escape' => false));
} else {
echo $this->Paginator->sort('published', 'datum', array('direction' => 'desc', 'escape' => false));
}
And eventhough the url does change now, the results of the sort are still ordered ASC.
So my question is:
How can I make an url in routes, combined with :page, for a specific sort and direction?
If you need more information, let me know.
And thank you in advance =]