structure for Admin and user panel in CodeIgniter? - php

Is this the structure to follow: for creating a structure for user and admin
is anything like this???
application ->
controllers
->manage folder
->admin controller files
->user controller files
models->
all model files are created her e in this single folder
views->
>manage folder
->admin views files
->user views files
Then what about the default controller we set in the config.php? And again in the views folder we used to create subfolders as pages and templates, right?
So please help me to form a structure by clubbing all these points.

Basically there is no standard structure. If You wish to separate admin panel from user interface - You can do this in Your own way.
HMVC will help you to achieve this. For my solution, I use below format:-
application ->
modules ->
module_name
under module_name folder I use below:-
controllers ->
manage ->
admin controller file
controllers ->
user controller file
models -> model file
views ->
manage -> admin views file
views ->
user views file

For my projects I create folders named "admin" in controller , model and view folders and put administration code there.
but this practice can leads to application vulnerabilities. "www.exsample.com/admin" can be a very easy target for automated hacking tools. so pickup random hard to guess string and make a redirect using .htaccess or routes.
eg:
"www.exsample.com/Gh567R"

Related

codeigniter inherints controller from controller

I have Admin.php as contrller for dashboard,signin and logout
but in my application
the admin user can edit news or add news I wanna separate news & admin controller and news controller work under admin
to understand my I wanna URL like http://localhost/nkmf/admin/
after admin if I write news get my news dashboard
and the URL be Like: http://localhost/nkmf/admin/news/
and after news if I enter
editeNews open editing form for selected news
and URL be like http://localhost/nkmf/admin/news/editNews?id=
create sub folders named admin,news in controller folder
move your admin.php controller to the new subfolder named admin.
so you can access it by
http://localhost/appname/admin/controller_name/function_name
As far as I have understood from your question the way you can achieve this is by either creating or overriding the .htaccess file or routes method. In which define your required url which leads to the the particular filename.php file. But for this you must know how to access and define the .htacess file or the routes class. If you are capable of handling htaccess file with regex, then you got it
Remember the codeIgniter url structure is http(s)://domain_name/sub_division/controller_name/function_name/parameter

Codeigniter HMVC and standart Codeigniter controllers

I have admin module (modules/admin) with controller admin (modules/admin/admin).
I need put new controllers of admin to Codeigniter controllers folder (application/controllers/admin/new_controller), but when i go to site.com/admin/new_controller – 404. Why I need it? I want to admin module was every customer the same, but the other controllers must be unique for each project, thats why I need to put new controllers to application/controllers/admin/ folder.
Is it possible to do this?
Codeigniter 3 and Wiredezignz HMVC (https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc)
Ok, I don't know if it's the right decision, but I change name of folder: application/controllers/admin to admin_unique
and add to application/configs/routes.php two lines, example:
$route['admin/(login|logout|index|settings|users)'] = 'admin/admin/$1';
$route['admin/(.*)'] = 'admin_unique/$1';

Codeigniter - Forgot to make an admin folder in controller and just created an admin.php controller

I created a controller called admin.php and placed it in the controllers folder. I was working on this "users" system where I was coding the things to edit, create, manage users. I made functions like users, edit_user, etc so when visited, it looked like http://localhost/admin/users, http://localhost/admin/edit_user
I am finally done that part.
Now, I am working on the site section of my panel where I will be able to edit the site. I just realized that I needed to create an 'admin' folder in the controllers folder so I could make a brand new users.php controller and place all my functions for managing users there.
I have no idea what to do. I don't want to put everything from the admin panel in a single admin.php file. I tried creating a new admin folder but I realized I have to change the url's to everything.

PHP Separate admin controllers CODEIGNITER

I have some basic controllers and admin controllers, I'm trying to separate them in folder to avoid things like this one:
controllers/user.php -> general users
controllers/a_user.php -> for admin users
I've read some things about route but couldn't find a way to do that.
Thanks in advance for any help.
Create a subfolder inside controllers folder and place your admin controllers in there.

share models, libraries and helpers across both the front and backend

I created one application in codeigniter. But Now I want to move that to admin side. I have read 3 methods from http://philsturgeon.co.uk/blog/2009/07/Create-an-Admin-panel-with-CodeIgniter. Here I decided to use second one.
I that I created an admin folder in controller, admin folder in views,admin folder in css, and an admin folder in js to store the files like admin side controller, admin side views , admin css and admin js. I have set $route['admin']='application/admin';
And my question is:
When I access the file http:example.com/admin I am getting the page without js and css. How to solve that.
And one more question:
$this->load->views('add_user'). This statement changed to $this->load->views('admin/add_user')
Its difficult to change each and every page.
You can share models and libraries between applications by using CI 2 "Packages". Have a look in the Loader documentation to see how that works.

Categories