Welcome Guest, Not a member yet? Register   Sign In
Best Practice for separation of User- and Admin-Views?
#1

[eluser]hkolbe[/eluser]
Being new to PHP/CI I wonder what is the best way to implement two "displays" (can't find the right word for it, wanted to avoid "views" for ambiguity) of nearly the same data.

The admin-view should include controls to add, edit and delete items and display items that are not visible for the normal user.

Is it a good idea to put all of this in one view? Surely it messes up the code, but it's only one page to maintain. Are there reasons (security, speed etc) to make two different views?

How do you handle this?
#2

[eluser]steelaz[/eluser]
What I usually do is use following structure ("home" is my default controller):

Code:
/application/controllers/home.php -> example.com/
/application/controllers/register.php -> example.com/register/
/application/controllers/admin/home.php -> example.com/admin/
/application/controllers/admin/dashboard.php -> example.com/admin/dashboard/

I share models and libraries, but separate views for organization:

Code:
/application/views/public.php -> public template
/application/views/admin.php -> admin template
/application/views/public/ -> public view files, usually grouped by controller
/application/views/admin/ -> admin view files, usually grouped by controller
#3

[eluser]hkolbe[/eluser]
Thanks for your answer - it's quite obviously the right way, I suppose.




Theme © iAndrew 2016 - Forum software by © MyBB