Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Codeigniter MY_Controller Question
#1

[eluser]riwakawd[/eluser]
I would like to know if I have set up my_controller.php correct first time setting it up like this no errors array working. Just want to make sure it OK way i am doing? I have been having problems with hmvc so just thought about using MY_Controller.

MY_Controller

Code:
<?php

class MY_Controller extends CI_Controller {}

class Controller extends MY_Controller {

public function header($data) {
  $this->load->view('theme/default/template/common/header', $data);
}

public function menu() {
  $this->load->view('theme/default/template/common/menu');
}

public function column_left() {
  $this->load->view('theme/default/template/common/column_left');
}

public function column_right() {
  $this->load->view('theme/default/template/common/column_right');
}

public function footer() {
  $this->load->view('theme/default/template/common/footer');
}
}

Controller

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends Controller {

public function index() {
  $data['title'] = "Welcome To Codeigniter";

  $data['header'] = $this->header($data);
  $data['menu'] = $this->menu();
  $data['column_left'] = $this->column_left();
  $data['column_right'] = $this->column_right();
  $data['footer'] = $this->footer();

  $this->load->view('theme/default/template/common/home', $data);
}
}

view file home.php

Code:
<?php echo $header;?><?php echo $menu;?>
<?php echo $column_left;?>

<?php echo $column_right;?>
<?php echo $footer;?>
#2

[eluser]ivantcholakov[/eluser]
You want to get away from HMVC, but code you presented is not good. I don't want to comment it in details. Better try to resolve the initial problem about HMVC instead of creating new problems.
#3

[eluser]riwakawd[/eluser]
[quote author="ivantcholakov" date="1405483880"]You want to get away from HMVC, but code you presented is not good. I don't want to comment it in details. Better try to resolve the initial problem about HMVC instead of creating new problems.[/quote]

I re-downloaded hmvc and tried it with CI 2.20.

I think there is route issue now. Not able to do way was before. Unable to call a second controller index if in one folder. I have always used same htaccess no problems until now. And config and every thing set up OK.

modules /

modules / admin /

modules / admin / setting /

modules / admin / setting / setting.php

modules / admin / setting / store.php

$route['setting/setting'] = "admin/setting/index"; // working

$route['setting/store'] = "admin/setting/store/index"; // Not working

It use to be able to work but since re downloaded hmvc and codeigniter CodeIgniter V 2.2.0 (Current version) not working

I am over hmvc not going to get some one to make my own.
#4

[eluser]Tim Brownlaw[/eluser]
This kind of reminds me about a dog walking through a door with a stick in it's mouth.

The day before it happily walked through the door with the stick... but today it couldn't and no matter how hard the dog tried ( using the same approach as it did yesterday ) get through that door...

Now the reason that it became a problem today could be...the stick could be longer or the door is not as wide...

But if the dog took a different approach to the same problem, then the length of the stick and the width of the door is no longer an issue and he can bring his stick through the door without going "THUNK" ( or whatever noise a dog with a stick in its mouth hitting the doorway makes.)



#5

[eluser]riwakawd[/eluser]
[quote author="Tim Brownlaw" date="1405515950"]This kind of reminds me about a dog walking through a door with a stick in it's mouth.

The day before it happily walked through the door with the stick... but today it couldn't and no matter how hard the dog tried ( using the same approach as it did yesterday ) get through that door...

Now the reason that it became a problem today could be...the stick could be longer or the door is not as wide...

But if the dog took a different approach to the same problem, then the length of the stick and the width of the door is no longer an issue and he can bring his stick through the door without going "THUNK" ( or whatever noise a dog with a stick in its mouth hitting the doorway makes.)



[/quote]

This was posted earlier before I spoke to you there was no kneed to reply to this. Don't use it any more MY_controller.php
#6

[eluser]ivantcholakov[/eluser]
@riwakawd

I don't like your folder structure, you are trying to put the whole administration panel within a single module. It will grow beyond manageability. The very same effect will happen if you put your admin/ directory under the common controllers/ directory. I don't see the benefit for using "modules" feature this way.

Anyway, this is my subjective point of view. On the other hand you may see how PyroCMS (some older version) organizes its front-end and its administration panel, it could give you a working idea.

If you insist on your way (that I don't like), then you may test the first project of mine that I've mentioned here: http://ellislab.com/forums/viewthread/245776/. As far as I can remember, for HMVC I added a possibility for one additional directory level for controllers. You may try to see if it is suitable for you.
#7

[eluser]Tpojka[/eluser]
Controller shouldn't be used as name for anything.




Theme © iAndrew 2016 - Forum software by © MyBB