Part of the EllisLab Network
   
 
Application design, advise needed.
Posted: 01 February 2007 06:37 AM   [ Ignore ]  
Summer Student
Total Posts:  2
Joined  02-01-2007

Hi,

After checking out a list of frameworks I think CodeIgniter is the framework I will use in future projects.
So I am new to CodeIgniter and the MVC way of application design, but have alot of experience in PHP and OOP. As a practice I am creating a simple website with a front and back-end. I am not sure the way I want to create it is the “smartest” and hope one of you can give me some advise.

The site contains pages without frames with 5 menu-items (Home/Text1/Text2/Contact/Members). For now I am planning to create 5 controllers. Because Text1/Text2 are actually the same (the text is read from the database) it feels wrong to have 2 different controllers for this. Should I use one controller and route both items?

The menu is on all pages the same. I want to create a Menumodel and load it in the constructor of each controller. Then parse the view into a menu-variable (so multi-views). Is this the way or is there a better one.

Because the pages all contain the same constructor (where the menu is loaded and other cosmetic stuff is handled) isn’t it better to create an Controller-class and let all controllers used in the application be extensions of this class. Or is this not the way it should be done in MVC? If so, does this class also belong in the controller-directory?

As you probably noticed in my post, I am a bit confused about this.

Thanks in advanced for your reaction!

Profile
 
 
Posted: 01 February 2007 01:35 PM   [ Ignore ]   [ # 1 ]  
Research Assistant
RankRankRank
Total Posts:  552
Joined  06-17-2006

Your final implementation is dependant on how you approach the analysis and design phase of your development.

I suggest its best to think about the controllers as representing the business objects. In other words, concepts that can implement business rules.

Most of the times, your controller will correspond to a database entity. For example. I understand that the “customer” business object is required. ‘Customer” also happens to be a table in my database because I need to store info about this.

However, I could also have a business object of (say) security, which may not have a corresponding database table.

Follow so far?

Now these business objects allow certain operations. For example:
- A customer may be created.
- A customer may be searched.
- A customer may be blacklisted.

Generally these operations will be available by the controller. You msy need to restrict the scope of these operations. for example, and external interface (application form?) may create the object, but some internal event (non-payment) may blacklist the customer.

From a design point of view I normally:
1. Ask myself what business objects will be represented by the application. These are my controllers.
2. Ask myself what operations the business objects will allow These are my controllers methods.
3. Design the methods using the “black-box” method. ie:
    a) What goes in (input)
    b) WHAT the operation/method does (“black-box”)
    c)  What comes out (output)
4.Design my input and output (forms, database tables, etc_
5. Design the details of 3(b). ie. Now concentrate how HOW the operation does WHAT from 3(b).

How does that match with your current design?

 Signature 

CodeCrafter - Open Source Code Generation for CI

Profile
 
 
Posted: 01 February 2007 01:56 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  9
Joined  09-13-2006

Read this topic: http://codeigniter.com/forums/viewthread/45653/
It clears somethings to me about how to control a dinamic menu and embed him into a view.

 Signature 

Brazilian programmer
http://engcomputacao.com.br

Profile
 
 
Posted: 02 February 2007 01:54 AM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  2
Joined  02-01-2007

thanks for the replies!
The other way I was thinking about is what I found in the post Rodrigo pointed out. Fragment caching, this felt the most natural for me. So requiring an url from your view like http://localhost/menus/mainmain/. I’ll go for that. Though I am not sure it’s really the right way of using MVC, but better to define my menu in every controller.

—Edit—
After all I didn’t go for fragments. While I will use it to load my generated image-titles. Though I want to do this separated from CodeIgnation to prevent loading the whole framework at every request. For the menu I created a Library which builds my page layout and I can call it with simple functions. But okay, don’t know if it’s useful to anyone to know wink

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 66425 Total Logged-in Users: 34
Total Topics: 84783 Total Anonymous Users: 1
Total Replies: 454963 Total Guests: 231
Total Posts: 539746    
Members ( View Memberlist )
Newest Members:  csaturkeytherendStudioGeorgiaJZeerfedegheEdgedcenticeRoger_Mxcamilojoostvaningen