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
Related
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';
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.
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"
I am new to codeigniter so please excuse my stupidity.
I am building a client portal and I have my admin / client login setup I am currently working on the admin area first so I have my controller for admin setup and it loads a view stored;
views (folder) -> admin (folder) -> admin-view.php
I wanted to keep all my admin panel views in the folder admin within the views folder.
Anyway so I have setup my links to pages in the admin panel like;
Client Companies<br/>
Client List<br/>
Rigs / Platforms<br/>
Now I understand that when you call a url like I have /admin/ is the controller and /company/ is the function which is called.
Now I would like to call a controller for company for this page because I have a lot of code in the company controller which defines what views and what data to pull for the company page of the admin panel.
Right now my function in admin for company looks like;
function company(){
log_message('debug', 'company_view Function Ran');
$data['page_title'] = 'Bomar Client Portal - Admin Area';
$this->load->view('admin/header', $data);
$this->load->view('admin/admin_navigation');
$this->load->view('admin/company_view', $data);
$this->load->view('admin/footer');
}
which I would like to replace just to call the company controller, I have looked into similar questions for calling controllers from controllers and everyone recommends against it.
So if I shouldn't call the controller for company from the admin controller how would I keep the url to point to /admin/company/
I know I could easily point to /company/ and it would render the page using the controller for company but I would like to keep the admin bit in the url if you understand where im coming from? is this a case of "you can't do it stop being so picky!"?
read up on codeigniter URI routing here:
http://ellislab.com/codeigniter/user-guide/general/routing.html
allows you to set up redirects to other controllers
I am trying to use pimcore but i am stuck with routes.
Still their is not so much detailed documentation on routes how to create & use them.
I also want to create URL like http://www.example.com/controller/action but i did not get any way to do it.
Thanks
Controllers/Actions are handled by documents in Pimcore. Just asign a controller and action to a document and the route will be generated by Pimcore.
It is explained in the documentation: Documents
On the other hand, you can use magic parameters to access to a controller/action directly:
/?controller=myController&action=myAction
Hope this help.
If you want to create routes for your controller action then you have open your pimcore admin.
In that your home url is shown, right click on the home in Documents panel 'Add Page'.
A new tab is opend with name home, in that you have to go for settings panel.
In settings panel you can specify your Controller, Action, Path(your route), key(your key name for that Action).
So the url will be shown as (home path)/(key name)