Welcome Guest, Not a member yet? Register   Sign In
routes help
#11

[eluser]dippy[/eluser]
anyone have some input on this? or can it not be done?
#12

[eluser]BrianDHall[/eluser]
[quote author="dippy" date="1256614431"]I have the following in my routes:
Code:
$route['services/:any'] = "services/section";
so i can goto a url like this: 'services/towing' and the php will pull that sections info into the page view.

and then i also want to have a url like the following: 'services/towing/company-name' - and have that route to another function in the services controller to pull that's company info.

can this be done?

when i tried to do this all i kept getting was the section.

so i added this for a temp. solution.
Code:
$route['search/:any'] = "services/search";

but id like to have it under services/section in the url.

any suggestions?[/quote]

Code:
$route['services/(*+)' = "services/section/$1";

So services/towing would remap to services/section/towing, and services/towing/company would reroute to services/section/towing/company
#13

[eluser]dippy[/eluser]
Thank you
#14

[eluser]dippy[/eluser]
Do i make the section function in the services controller to be able to handle company names as well as the section name?

how would the function be setup?
#15

[eluser]dippy[/eluser]
[quote author="BrianDHall" date="1257387164"][quote author="dippy" date="1256614431"]I have the following in my routes:
Code:
$route['services/:any'] = "services/section";
so i can goto a url like this: 'services/towing' and the php will pull that sections info into the page view.

and then i also want to have a url like the following: 'services/towing/company-name' - and have that route to another function in the services controller to pull that's company info.

can this be done?

when i tried to do this all i kept getting was the section.

so i added this for a temp. solution.
Code:
$route['search/:any'] = "services/search";

but id like to have it under services/section in the url.

any suggestions?[/quote]

Code:
$route['services/(*+)' = "services/section/$1";

So services/towing would remap to services/section/towing, and services/towing/company would reroute to services/section/towing/company[/quote]


i get the following when i replace the route with the following.
Code:
$route['services/(*+)' = "services/section/$1";

Code:
A PHP Error was encountered

Severity: Warning

Message: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 11

Filename: libraries/Router.php

Line Number: 281
#16

[eluser]BrianDHall[/eluser]
That's a new one on me, whoops - try changing that * to a . and you should be ok then Smile
#17

[eluser]dippy[/eluser]
[quote author="BrianDHall" date="1257389395"]That's a new one on me, whoops - try changing that * to a . and you should be ok then Smile[/quote]

ahh thanks. works now.

now would i just inside that section function use uri->segment to run thru different models?
#18

[eluser]BrianDHall[/eluser]
You can, or use function parameters - personal preference, really.
#19

[eluser]dippy[/eluser]
[quote author="BrianDHall" date="1257396871"]You can, or use function parameters - personal preference, really.[/quote]

can you give me a quick example on what you mean?

like this?

Code:
function section($section, $company) {


}

??

is that what you mean?
i was thinking this way:

Code:
function section() {

$section = $this->uri->segment(2);
$company = $this->uri->segment(3);

}




Theme © iAndrew 2016 - Forum software by © MyBB