[eluser]Cgull[/eluser]
Hello,
I am using ci2.1.3 and HMVC
I have this folders structure:
c:/sites/mysite
appclication
system
public_html
I have a controller in appcliation/core/MY_Controller:
Code:
<?php if(!defined('BASEPATH') OR exit('No direct script access allowed'));
class MY_Controller extends MX_Controller
{
public $data = array();
function __construct()
{
parent::__construct();
$this->data['errors'] = array();
$this->data['site_name'] = config_item('site_name');
}
}
I have a controller in application/libraries/Frontend_Controller:
Code:
<?php if(!defined('BASEPATH') OR exit('No direct script access allowed'));
class Frontend_Controller extends MY_Controller
{
function __construct ()
{
parent::__construct();
// Load stuff
$this->load->model('page_m');
// Fetch navigation
$this->data['addthis'] = FALSE;
if($this->uri->segment(1) == '')
{
$this->data['slug'] = 'homepage';
}
else
{
$this->data['slug'] = $this->uri->segment(1);
}
}
}
I have this controller in: application/controllers/page
Code:
<?php if(!defined('BASEPATH') OR exit('No direct script access allowed'));
class Page extends Frontend_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('page_m');
}
public function index()
{
$this->data['page'] = $this->page_m->get_by(array('slug' => (string) $this->data['slug']), TRUE);
count($this->data['page']) || show_404(current_url());
$this->data['meta_title'] = $this->data['page']->title;
// Fetch the page data
$method = '_' . $this->data['page']->template;
if (method_exists($this, $method))
{
$this->$method();
}
else
{
log_message('error', 'Could not load template ' . $method .' in file ' . __FILE__ . ' at line ' . __LINE__);
show_error('Could not load template ' . $method);
}
// Load the view
$this->data['subview'] = $this->data['page']->template;
$this->load->view('_main_layout', $this->data);
}
private function _homepage()
{
$this->data['addthis'] = TRUE;
$this->data['body'] = $this->data['page']->body;
}
private function _page()
{
$this->data['addthis'] = TRUE;
}
}
This is my routes file:
Code:
$route['default_controller'] = "page";
$route['(:any)'] = "wp_pages/$1";
$route['(:any)'] = "page/$1";
Trying to go to mysite in the browser I get this error:
No direct script access allowed
Why is that?
I thought I should put this line on top of every controller?
Code:
<?php if(!defined('BASEPATH') OR exit('No direct script access allowed'));
Or should I not bother with that as my application and system folders are out of the root folder?
Thanks,
Sigal