Welcome Guest, Not a member yet? Register   Sign In
How to structure my site
#1

[eluser]Hamilogre[/eluser]
I'm new to CI, I think I have read the entire user guide, and wiki, and I have also read a lot on the forums. I have a question about how to structure my application.

The site is for a doctor's office where there are 7 doctors in the practice. I want to build a backend for the practice administrator to be able to edit things herself so it doesn't require code changes when things need to be updated. What I'm working on now, is the doctor's main page that lists all the doctors, and the individual doctor's pages that shows their bio.

For the doctor's page, I want my URL to be http://www.mysite.com/doctors. (Fine, all I do is tell the index function to load the doctors/index view, as shown below:

Code:
function index()
{
    $this->load->view('doctors/index');
}

Now for each individual doctor, I want the URL to be: http://www.mysite.com/doctors/doctorlastname and I'm not sure how to setup my functions in the doctors controller to do this, so that my site is truly dynamic. If I setup a function for each doctor's last name, that would defeat the purpose of making it dynamic, as I want to only store each doctor's name 1 time in my database.

What I have come up with is to have a function called bio in my doctors controller to load the view of the appropriate doctor. Then I configured my routes to do this:
Code:
$route['doctors/:any'] = "doctors/bio"

And here is my bio function:
Code:
function bio()
{
    $this->load->view('doctors/' . $this->uri->segment(2));
}

I think this function may need some reworking too, it seems to simple to me, any suggestions?

That works fine, but now what if I want to make a url to edit the bio something like this: http://www.mysite.com/doctors/doctorlastname/edit. How do I set it up so that that url doesn't get routed to doctors/bio.

One question about views too. Say the above code segment loads the view doctors/smith. In my doctors/smith view, it it appropriate for me to call my header and footer view from within the doctors/smith view? Not sure what the best way to set this up is. I noticed that you can only call one view from a controller.

Here is what my doctors/smith view would look like:
Code:
<?php $this->load->view('global/header'); ?>
<p> Dr. Smith Bio</p>
&lt;?php $this->load->view('global/footer'); ?&gt;

Is this the proper way to include my header and folder?

I think I am close to fully understanding how this works, but I need some assistance getting a grasp on it. Any help would be appreciated.

Thanks.


Messages In This Thread
How to structure my site - by El Forum - 08-17-2007, 04:13 PM
How to structure my site - by El Forum - 08-17-2007, 05:04 PM
How to structure my site - by El Forum - 08-18-2007, 04:16 AM
How to structure my site - by El Forum - 08-18-2007, 01:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB