Welcome Guest, Not a member yet? Register   Sign In
Organizing Your Controllers into Sub-folders
#1

[eluser]Unknown[/eluser]
hi ,please how can i specify the url of the method redirect whet i have this tree :

project/application/backoffice/login/controllers/login.php
#2

[eluser]ELRafael[/eluser]
I believe that your structure is wrong bejimed.

Try to organize like this:

Code:
project/
  - application/
    + config/
    - controllers/
      - backoffice/
        login.php
    + core/
  + system/

You can access with this url:
http://example.com/index.php/backoffice/login

Try to check this: https://bitbucket.org/wiredesignz/codeig.../wiki/Home
#3

[eluser]defectivereject[/eluser]
i have a CMS
My controller folder consists of just folders for each section of the CMS
Admin
Training
HR (e.t.c)

then the controllers are within them. Some have one some have 2 or 3.

If i wanted the personnel controller in the HR folder it would be

http://localhost/project/index.php/hr/pe...controller

or if you wanted the courses controller in the training folder

http://localhost/project/index.php/train...controller

Hoping you were understood correctly
#4

[eluser]ELRafael[/eluser]
http://localhost/project/index.php/hr/pe...controller

For this URL, your structure:

Code:
- application/
  + config/
  - controllers/
    - hr/
      personnel.php
    - trainning/
      courses.php

And your personnel.php is something like that:

Code:
class Personnel extends CI_Controller {

  public function functioninthatcontroller()
  {
    echo 'Hello from hr/personnel/functioninthatcontroller';
  }
}

IMHO:
It's a bit confusing. Why you just set the folder for backoffice?
Code:
- application/
  + config/
  - controllers/
    - backoffice/
      personnel.php  <-- Admin Controller
      courses.php    <-- Admin Controller
    personnel.php    <-- Public Controller
    courses.php      <-- Public Controller

Now, everytime you need to access your CMS, just put "backoffice" before the controller.

If you don't wanna use this, tell me exactly what's wrong with this structure.
You can access the controller typing the folder name in the URI Wink
#5

[eluser]defectivereject[/eluser]
nope
each controller extends either a MY_Controller, a Public_controller or an Admin_controller

then each function within each controller has additional checks for Usertype built in.

and it's set in such a way so you know what folder deals with what modules on the CMS.
I say CMS but it's more of a business management system.
Handles 700 users with 16 access levels and 9 group access levels. as well as 70+ dept levels!!!

also if i get run over or die. someone coming in can see it organised a little more efficiently,

This folder controls that module, that folder controls that module.
Also
each folder could then be deleted and have no knock on effect to the rest of the system.
Code:
class Welcome extends Public_Controller {
        
    function __construct() {
        parent::__construct();

    }
                
    function index() {
        $data['main'] = 'home2';
        $data['title'] = 'Connected';
        $data['docs'] = $this->mdocs->get_latest_five();
        $data['no_tasks'] = $this->widgets->num_tasks();
        $data['no_messages'] = $this->widgets->num_messages();
        $data['no_events'] = $this->widgets->num_events();
        $data['dashevents']= $this->widgets->getdashevents();
        $data['mytasks'] = $this->widgets->showminedash();
        $data['peeps'] = $this->widgets->peeps_names();
        $data['safety_message'] = $this->widgets->safety_messages();
        $data['message'] = $this->session->flashdata('message');

        $data['uid'] = $this->session->userdata('uid');
        $data['usertype'] = $this->session->userdata('usertype');
        $data['sidebar'] = 'templates/newsitenav';
                
        $data['scripts'] = 'templates/scripts/sitescripts';
        $this->load->vars($data);
        $this->load->view('templates/sitetempaudit');
    }
Code:
&lt;?php
if (! defined('BASEPATH')) exit('No direct script access');
class Administration extends Admin_Controller {

    function __construct() {
        parent::__construct();
    }
function backup() {
        $this->load->dbutil();
        $settings = array(
              'tables'      => array('tables'),
              'ignore'      => array('subscribers'),          
              'format'      => 'zip',             // gzip, zip, txt
              'filename'    => 'mybackup.sql',  
              'add_drop'    => TRUE,
              'add_insert'  => TRUE,
              'newline'     => "\n"
            );
        $backmeup =$this->dbutil->backup($settings);
        $this->load->helper('file');
        write_file('./backmeups/backup.zip', $backmeup);
        redirect('administration/index');

    }
#6

[eluser]ELRafael[/eluser]
So it's better to use HMVC. I use it here and i'm very happy.

I have a folder called modules
Code:
- application
  + config/
  + controllers/
  - modules/
    - hr/
      + config/
      - controllers/
        backoffice.php
        hr.php
      - models/
        hr.php
      + views/

So when i delete modules/hr, the only thing that still exists is the assets.
Code:
+ application/
- public_html/
  + css/
  + images/
  index.php  <-- The CI index.php
  + js/
+ system/
#7

[eluser]defectivereject[/eluser]
Nah. as you need a full config e.t.c. for each module that way.




Theme © iAndrew 2016 - Forum software by © MyBB