• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Where does this code go? Controller, model, helper or library?

My application is a web shop.
My default controller parses the URI - for instance, /category1/category2/product1, where category2 must be a child of category1 and product1 must belong to category2, otherwise an error message is shown.

Of course, the Category and Product models methods for the actually checking in the database, but the instructions are passed from my controller. If the current page is a category, the controller will also make a category tree and load the appropriate views. All in all, this is quite a lot of code in the default controller.

I wonder if I should perhaps put all these instructions in a library or a helper instead, as several controllers will need to do the same thing, basically. Or is it appropriate to put these instructions into a my Page model (which right now is only used to get title and meta information about the current page). What do you think?

I hope I've described my problem clearly enough. I figure you must have had many questions similar to this one, I've tried searching but I couldn't come up with usable search terms...

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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