• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Yet another project layout questions

Hi all, sorry to bother but I have a quick question. I am fairly new to all this so its probably a very easy answer if I get my questions across correctly Smile I am writing my first project using CI and I think its awesome, thanks for the hard work everyone.

I have a distinct set of controllers, views and models that deal with my data maintenance and I want to separate these off somehow now I am ready to build the main front end. I am sure that HMVC would be the way to go and I have read a lot about it but I can't get my head around it just yet. How easy is it to throw the models/views and controllers into separate subdirectories or should I just move the controllers out and leave the models/views in their existing locations?

Thanks in advance.

They already are in separate subdirectories. I'm pretty sure you can move them wherever you want. I know with views you can just stick the path right in the view() call, like so:
$this->load->view('subfolder/view', $data);

You can also place libraries and controllers into subdirectories. However, with controllers, you can only go one level deep, ie. ./system/application/controllers/subdir/controller_file.php.

Thats absolutely great thanks guys, I was getting a little confused because I read somewhere that I couldn't move Views in-particular around as I am using a Template Library thats expects views to be in the views folder. However if I can move models and controllers into subdirs of there main dir with no problems, thats fabulous.

Thank you very much Smile

The template library will look in the views directory, but should still support subdirectories, too. You'd just load your view using the relative path from the views directory. e.g. forums/main_view

Fantastic I am a happy guy.

Thanks again for your time.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.