Welcome Guest, Not a member yet? Register   Sign In
Controller Setup for Complex URL
#1

[eluser]Unknown[/eluser]
I have just recently started using CI (this is my first post, in fact), and I have run into my first issue.

I am not new to programming, but I am pretty new to MVC (took me a while to jump on the bandwagon, I guess). My first project is a project management system. Here is an example of how the data is setup.

Code:
Project
-Milestone
--Tasks
---Comments

In my mind, the URL to get a comment should look like this:
Code:
'http://mysite.com/project/1/milestone/2/task/15/comment/5'

So here are my questions:
1. How would I setup a controller to handle a URL like this? If possible, I would like to use seperate controllers for each object.
2. Is this the best URL setup to have? If not, what would work better?
3. As a side note, is it possible to use slugs instead of and id? Is this recommended?

Thanks in advance for the help.
-Jacob
#2

[eluser]bretticus[/eluser]
You could definitely setup complex routes to pass this data to a single controller method. Read up on URI Routing. If you insist on this URL schema, I highly recommend you take that route (no pun intended.)

However, you should never have one monolithic controller that does everything. Worse than that is one giant controller method that does everything. Smile

So, setup some custom routes to cover all the scenarios (might get big.) Afterall, this could be a cool way to keep context (thinking breadcrumbs here.) However, make sure you have a project method, a task method, etc. It will keep your development better organized and your code better optimized.

A slug is fine, but not necessary unless this is a public website and you need some search engine bot goodness. Of course, you'll most likely get better performance with an auto-incremented id to query by.




Theme © iAndrew 2016 - Forum software by © MyBB