Question

I used MVC before. Now I am a learning HMVC. I have product, product_category, product_description and product_images tables in my database. I want to display list of products in my website with basic product information. Clicking on a product will redirect to a different page and will display all the product related information. What is the best way to achieve this according to HMVC(Modular MVC) pattern?

  1. Should I create different modules for each table like product module, product category module etc..?(In this case I will have one model class in each module/model. I found this idea when searching internet)

  2. Should I create one module called products and put all the files related to this in that module? (In this case I will be having all the product, product_category, product_description product_images model classes under products/models)

  3. Should I follow a completely different implementation from the techniques I've mentioned above? (Please provide specific details to build this module)

(I'm using codeignitor for my development)

Thanks a lot!

Était-ce utile?

La solution

Lets simplify the things for you.

  1. If you have category as menu (Same as magento), i will recommend you to create new module for cateogry
  2. Coming back to product, you can manage all things with the 1 product controller.
  3. In category, category will have its own model to interact with database.
  4. In your product model, you can manage all kind of transactions in one model because they are part of product only.
  5. If you want to move bit advance, you can have a sql folder in each module so that you can install the and create tables when you just drop folder to modules. For this you can create a small script where, in regular interval of time, it will check the new modules, and if that script found some new modules, it will install the .sql file in the sql folder, which will update the database schema.

Hope this will help you

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top