Hi! I’ve successfuly installed Community Auth before a few months but wasn’t using it. Today I’ve installed the new version (2.0.0). It’s excellent, and I’d like to integrate it with my existing CodeIgniter website which has three columns layout and only one controller (Site). I don’t know how to merge it with 12 Community Auth controllers… Thanks!
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Site extends CI_Controller {
public function index(){
$this->home();
}
public function home(){
$this->load->model("model_get");
$data["results"] = $this->model_get->getData("home");
$this->load->view("site_header");
$this->load->view("content_home", $data); //col1, centered
$this->load->view("col2");
$this->load->view("col3");
$this->load->view("site_banner");
$this->load->view("site_footer");
}
Altazar, the main difference between your handling of views and mine is that I am nesting the views. When the third parameter of view() is set to true, it doesn’t immediately output, but instead makes that view available for use however you’d like it. You will notice that Community Auth uses a main template, located in views/templates. The content of each page is a nested view. So for instance, in the controller you will see:
$data = array(
'content' => $this->load->view('some_nested_view', '', TRUE)
);
Then, inside the main template:
<?php echo $content; ?>
If you want to have three columns, then you will need to add the columns to the template, then insert them through nesting:
// Controller
$data = array(
'left_col' => $this->load->view('left_column_content', '', TRUE),
'content' => $this->load->view('some_nested_view', '', TRUE),
'right_col' => $this->load->view('right_column_content', '', TRUE)
);
Revised main template:
<?php echo $left_col; ?>
<?php echo $content; ?>
<?php echo $right_col; ?>
Take a look through a few controllers and see how the content is inserted into a template. I’m sure you will quickly see how easy it is to create your own template.
