Welcome Guest, Not a member yet? Register   Sign In
Folders
#1

[eluser]NateL[/eluser]
I have an application that I wrote that I'm looking to revamp with CodeIgniter

It's an internal project that only our company uses. So we go to our site, log in, and then we can create a client. Lets say we have a client named Jon Doe

We click "create client", it shows them a field where they type in "Jon Doe". The script automatically creates a folder called jondoe (strips spaces, makes all lowercase) so now in order for Jon Doe to see what we're doing for him, he goes to our site/his folder - example.com/jondoe and up comes a list of his projects - example.com/jondoe/project1

project1 is a subfolder of jondoe, as well as project2 and project 3 etc.

I'm wondering if CodeIgniter can see that i've typed in example.com/jondoe - yet realize that jondoe is not an actual folder that exists on the server...

consider MySpace.com for example
you go to myspace.com/username and it takes you to that users profile, right? but there is not an actual FOLDER on myspace's server with that username - there would be MMMMMILLIONS of folders...that doesn't seem like a logical way of creating users.

any suggestions? Thanks very much!
#2

[eluser]roj[/eluser]
Do you need this to be a file based system? Surely a database would be easier?
#3

[eluser]NateL[/eluser]
Yes - sorry I should have clarified that. Right now, it IS a file based system, and I want to change that to a database based system, where when you type in oursite.com/jondoe it pulls all of the information out of the database for "Jon Doe", and that folder jondoe doesn't really exist...only the core files that run the system.
#4

[eluser]roj[/eluser]
From a codeigniter point of view you'll need to set up a controller to handle the clients and in order to get that exact uri setup you'll need to set a route to direct all traffic to that controller.
#5

[eluser]roj[/eluser]
Something along these lines i think
Code:
class client extends Controller
{
    
    function project()
    {
        // see if there's a specific project to get
        if($this->uri->segment(2))
        {
            // Get specific project info
        }
        else
        {
            // Get list of projects
        }
    }
    
}

and set a route
Code:
$route['.*']             = "client/project/$1";

would send all requests to the project function within the client class and so come from
Code:
example.com/jondoe/project1
#6

[eluser]NateL[/eluser]
Makes sense. Thank you very much!
#7

[eluser]roj[/eluser]
Personally i'd change the uri slightly to example.com/johndoe/project/1 and point the route just to the client class....that way easily allowing for things like client information (like: example.com/jonhdoe/details) ...but you know your own system better!




Theme © iAndrew 2016 - Forum software by © MyBB