Welcome Guest, Not a member yet? Register   Sign In
What do you call your main controller?
#11

(11-13-2015, 12:46 PM)DreamOfSleeping Wrote: Aweseome thanks! And thank you for your patience!

No problem Smile
Reply
#12

(11-13-2015, 12:25 PM)DreamOfSleeping Wrote: Thanks again for replying. I admit already knew the first half of what you said. I think it's my fault for not making myself clear. It's a complicated topic though.

If I had one page per controller. I could have a controller called "profile", which would show the users profile. I could have one called "home" which would show the users their home page. But what would I call the controller that deals with the website home, rather than the user home. Or would I just have one controller called 'home', and in the index it looks to see whether the user is logged in or not and shows the appropriate view?

Honestly, I would have a "Users" controller which contained methods to display the user's home page, profile, etc. Then I would have a "Home" controller (or whatever) to show the website home, and probably anything else I couldn't really put in a better location.

In Home/index, if I wanted the user sent to their home page when they are logged in, I would just redirect to Users/home or whatever is appropriate.

On the other hand, if you wanted more of a "single-page" design, or just wanted to use a limited number of controllers, you could use one "Home" (or whatever) controller, and have libraries/models retrieve the appropriate content based on the current user, or whatever other information is needed.

In any case, you can use routes to map URIs to controllers/methods as needed, so you can choose to have one controller with a lot of methods, or a lot of controllers with a few methods. You could even run everything through one controller with one method (more or less, as long as the method is named index or _remap).
Reply
#13

(This post was last modified: 11-13-2015, 01:21 PM by DreamOfSleeping. Edit Reason: missed out a word )

(11-13-2015, 01:05 PM)mwhitney Wrote: Honestly, I would have a "Users" controller which contained methods to display the user's home page, profile, etc. Then I would have a "Home" controller (or whatever) to show the website home, and probably anything else I couldn't really put in a better location.

In Home/index, if I wanted the user sent to their home page when they are logged in, I would just redirect to Users/home or whatever is appropriate.

On the other hand, if you wanted more of a "single-page" design, or just wanted to use a limited number of controllers, you could use one "Home" (or whatever) controller, and have libraries/models retrieve the appropriate content based on the current user, or whatever other information is needed.

In any case, you can use routes to map URIs to controllers/methods as needed, so you can choose to have one controller with a lot of methods, or a lot of controllers with a few methods. You could even run everything through one controller with one method (more or less, as long as the method is named index or _remap).

Thanks for the reply. That does seem to be more of an organized way of doing it. I'll give that a try.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB