School site with multiple sub schools - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: School site with multiple sub schools (/showthread.php?tid=23854) |
School site with multiple sub schools - El Forum - 10-23-2009 [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! School site with multiple sub schools - El Forum - 10-23-2009 [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 School site with multiple sub schools - El Forum - 10-23-2009 [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? School site with multiple sub schools - El Forum - 10-23-2009 [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. School site with multiple sub schools - El Forum - 10-23-2009 [eluser]yabune[/eluser] ok, I understand. I will try that. Thanks a lot! |