Welcome Guest, Not a member yet? Register   Sign In
School site with multiple sub schools
#1

[eluser]yabune[/eluser]
Hi,

I'm new to CI, but I really like the way to use it, so I'm trying to apply it to a site, but I have some questions about the proper use of CI in this situation.

It's a site for a school that is divided in two schools. The site is the same for the two schools (same template), but some contents is different for each school.

So I have, for example:
http://www.schoolsite.com/school1
http://www.schoolsite.com/school1/news
http://www.schoolsite.com/school1/classes
http://www.schoolsite.com/school2
http://www.schoolsite.com/school2/news
http://www.schoolsite.com/school2/classes

What should be the best way to program this?
Should I create 2 folders (school1 and school2) and put inside each one the classes I need? But I would like to use the same controllers for each school (so I don't have to repeat code), the difference would be the news (for example) to be specific to that school.
Maybe I should create a model for the news. But would I have to create two news controller classes inside each folder to call this model?

Thank you!
#2

[eluser]clip[/eluser]
[quote author="yabune" date="1256348015"]Hi,

I'm new to CI, but I really like the way to use it, so I'm trying to apply it to a site, but I have some questions about the proper use of CI in this situation.

It's a site for a school that is divided in two schools. The site is the same for the two schools (same template), but some contents is different for each school.

So I have, for example:
http://www.schoolsite.com/school1
http://www.schoolsite.com/school1/news
http://www.schoolsite.com/school1/classes
http://www.schoolsite.com/school2
http://www.schoolsite.com/school2/news
http://www.schoolsite.com/school2/classes

What should be the best way to program this?
Should I create 2 folders (school1 and school2) and put inside each one the classes I need? But I would like to use the same controllers for each school (so I don't have to repeat code), the difference would be the news (for example) to be specific to that school.
Maybe I should create a model for the news. But would I have to create two news controller classes inside each folder to call this model?

Thank you![/quote]

Maybe you could utilize the $this->uri->uri_to_assoc(n) from the URI Class
#3

[eluser]yabune[/eluser]
So, I would not create folder?
I would just have one news controller class and in this class I would use the URI class to check what school is in the url?

Would I have also to define some uri routing, so that I could have the school name before the class name?
#4

[eluser]clip[/eluser]
[quote author="yabune" date="1256349147"]So, I would not create folder?
I would just have one news controller class and in this class I would use the URI class to check what school is in the url?[/quote]

Correct!

Quote:Would I have also to define some uri routing, so that I could have the school name before the class name?

correct so if your url looked like this http://schoolsite.com/index.php/school/name/news your route would look something like this:

Code:
$route['school/:any/news'] = 'school/news';

That should do the trick.
#5

[eluser]yabune[/eluser]
ok, I understand.

I will try that.

Thanks a lot!




Theme © iAndrew 2016 - Forum software by © MyBB