Sinem Bozacı
Sinem Bozacı

Reputation: 45

CodeIgniter URL, File, Controller organization. What is the best way?

I am new at CodeIgniter framework with also MVC, thus i have confused how the organization should be.

I will write a large application. I need well organized File Structure.

For example, i have categories with also products, records etc.. which are unique to a category. I have a admin panel.

Here is my URL for controlling categories at admin panel:

Index(List of categories): mysite.com/index.php/admin/category/index Create(Creating new category): mysite.com/index.php/admin/category/create

First of all i need a dashboard for categories which shows their products, records etc.. I want the new url to be like:

mysite.com/index.php/admin/category/id/5
or
mysite.com/index.php/admin/category/name/category1
etc..

I want products url to be like:

mysite.com/index.php/admin/category/id/5/product
and records to be like:
mysite.com/index.php/admin/category/id/5/record

Of course i need to parse value's to products or records like:

mysite.com/index.php/admin/category/id/5/product/id/5
or
mysite.com/index.php/admin/category/id/5/product/create - to add new product to a category

As i said before my application is large I thought file organization something like this:

controllers/admin.php - admin controller
controllers/admin/category.php - category controller
controllers/admin/category/product.php - product controller
controllers/admin/category/record.php - record controller

I need your advices how to make organization. How can i show products unique to a category

Should My product controller extends from category controller etc.. Can you help and advice me please? Thanks.

Upvotes: 1

Views: 512

Answers (1)

TheFoxLab
TheFoxLab

Reputation: 704

Try to answer your question which is understand by me.

First of all CodeIgnitor with easy file structure.

Basic : 
   application/
              Controller/ put all controller 
              model/ put all model 
              views/ put view file 

 // In your case:

         controllers/admin.php - admin controller
         controllers/category.php - category controller
         controllers/product.php - product controller
         controllers/record.php - record controller

you have little mis-interpolation:

   mysite.com/index.php/admin/category/id/5/product/id/5

   GET method
   //serverpath(base_url)/controller/method(function)/para1/valu1/para2/valu2....

In your case category and product is conttroller.

please refer CI-codeIgnitor documents: http://codeigniter.com/user_guide/general/urls.html

Hope you understand.

Upvotes: 4

Related Questions