Welcome Guest, Not a member yet? Register   Sign In
help with routes (i think?)
#1

[eluser]jblack199[/eluser]
Alright, so here is a question and I am sure it will have to do with routes...

I am developing a project we'll call the url http://domain.com/debts

so under debts i have my codeigniter installed and functioning properly.. but there are multiple lists that I'll need to create (different pages) which will come off a master-list..

so first page:
list item 1
list item 2
list item 3

those would be 3 links to:

http://domain.com/debts/1
http://domain.com/debts/2
http://domain.com/debts/3

and so on...

now when I click on one of the links -- it takes me to the 2nd page which is a list of debts for that 'client' as input in the database.. but i can also add debts... so my url for that would be: http://www.domain.com/debts/1/add so the 1 is the variable number...

but to throw something else in the mix, here is yet another conundrum for you... in the same list (/debts/1/) I can delete/edit on of the debts... so my URL's for them would be (/debts/1/delete/54) or (/debts/1/edit/125)

the #'s are the only variable information that would be driven from the database.. so -- how exactly to do it...
#2

[eluser]kilishan[/eluser]
You could either use routes or the _remap method in your controller. Either one would be pretty simple. Here's the routes version:

Code:
$route['debts/(:num)/[a-z_]') = 'debts/$2/$1';

Basically what this does is to reverse the order of the uri segments as they come into your controller. So, it would still be calling the debts->edit method, with the third uri available as the only parameter to that method.

Code:
class debts extends CI_Controller {
    public function edit($id=0)
    {
        ...
    }
}
#3

[eluser]byde[/eluser]
im not very sure but ill try something like this
Code:
class Debts extends CI_Controller {
    public function index($index, $function)
    {
        eval("\$this->$function(\$index)");
    }

    public function edit($index)
    {
        ...
    }
}
#4

[eluser]danmontgomery[/eluser]
eval: bad, routing: good




Theme © iAndrew 2016 - Forum software by © MyBB