I am trying to make the default home page route to certain category by default.
in my routes.php file I have re-routed the publish new action to the home page, as I want the post an ad form to be the home page, but I keep encountering errors when trying to add the query string "?category=wanted-ads"
My goal is I'd like it to default to the form options that are part of the /publish-new.html?category=wanted-ads page.
Apologies for a simple question, I'm new to php and the kohana framework and I'm using the open classifieds script to create a classifieds site.
Thanks in advance.
URL::title(__('publish new'))
Route::set('post_new', URL::title(__('publish new')).'.html')
->defaults(array(
'controller' => 'new',
'action' => 'index',
));
Did you try get the query string params manually ($_GET)? If yes, what is shown?
By a fast reading in Kohana docs I found something that could help you. Instead you to pass desired category via query string, you can to pass via params.
Route::set('post_new', '/post_new/category/:<category>', array('category' => '.*'))
->defaults(array(
'controller' => 'new',
'action' => 'index',
));
To get this param you just do this:
// From within a controller:
$this->request->param('category');
// Can be used anywhere:
Request::current()->param('category');
This works perfectly in many others frameworks, probably works fine in Kohana too.
Source: https://kohanaframework.org/3.2/guide/kohana/routing#examples