Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
Routes sending parameters
lucianoreis
September 2014
Hello people,
Does anyone know how I do with static routes parameters?
I tried this way but does not work.
<?php
return array(
'_root_' => 'index/index',
'_404_' => 'index/404',
'services' => array('institucional/index/&category=1', 'name' => 'services'),
'company' => array('institucional/index/&category=2', 'name' => 'company'),
);
kazumi
October 2014
What do you mean with "static routes parameters"?
Harro
October 2014
Do you mean GET variables? Like "institucional/index?category=1"?
Fuel doesn't work with GET variables, it works with URI segments for parameters, like "institucional/index/category/1" which can be routed without problems.
lucianoreis
October 2014
Did the way you told me, but how do I get the value of the thread?
Thus returns under empty.
<?php
return array(
'_root_' => 'index/index',
'_404_' => 'index/404',
'services' => array('institucional/index/category/1', 'name' => 'services'),
'company' => array('institucional/index/category/2', 'name' => 'company'),
);
Controller:
public function action_index()
{
$view = View::forge('institucional/index');
$view->category = $this->param('category');
$this->template->content = $view;
}
View:
<h1><?php echo $category;?></h1>
Harro
October 2014
As a parameter of the action method.
If you provide a default:
public function action_index($category = null)
{
}
then the value is optional (i.e. "institucional/index/category" will work too), but of you don't
public function action_index($category)
{
}
then the parameter is required, and "institucional/index/category" will throw a HttpNotFoundException (a 404).
lucianoreis
October 2014
Problem solved!
It worked perfectly.
Thanks man.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
October 2014
kazumi
October 2014
lucianoreis
October 2014