Welcome Guest, Not a member yet? Register   Sign In
Controller function naming - Best Practices?
#11

[eluser]dabadguy[/eluser]
Thanks SitesbyJoe. I'm going through the form validation portion of the user guide right now.
#12

[eluser]jedd[/eluser]
[quote author="dabadguy" date="1266104646"]
OK I'm just trying to get an idea of what the site design would be then. Say I had a simple site with 1 database table called users. Has 4 fields, ID, username, password, accesslevel.

User goes to the site and is presented with a login form.

User logs in, if they are admin level, can see all users and add new users. If they are not admin level, they just see their user info (username and accesslevel).

What would I have for controllers?
[/quote]

Probably not a great example, as it's a very simple arrangement.

If you can spare the time, start looking through previous threads - particularly any with replies from Colin Williams - where the subject refers to back-end, back office, admin and other synonyms.

From things that users never see any aspect of, then it makes sense to have those interfaces tucked away in an admin corner - but for things where admins can do more than a normal user (but a normal user can still do *some* stuff) - I think this is where the camps split. Don't quote me on this, btw.

As I say, and to get back to your question, if you think of controllers as nouns and methods as verbs, I find things often start to drop into place a bit more clearly. I gather that you're hip with your own (or other) auth models, and mechanisms for testing whether users have admin privs, in controllers and views(?).
#13

[eluser]Udi[/eluser]
I separate my application into modules,
for example "user" has its own folder in Controllers, Models and Views directories.

the class for adding new user called Add, basically it'll have 2 main methods:
index() - showing the form
process() - processing the forms data.

I'm always trying to make the names as "pretty" as possible an avoid using routing unless I really have too, because then the url is "fake", if other developer comes to work on my app he'll might get confused.


To separate the admin zone and user zone - I just add method for authentication check it each class that belongs to Admin.
So user/view/userID is open to everyone, but user/add only for admins. [Note that user is folder and add or view are classes]




Theme © iAndrew 2016 - Forum software by © MyBB