Welcome Guest, Not a member yet? Register   Sign In
Integrating Tank_Auth library into the template library - howto ?

looked around but could't find an example.

i'm using the template library: http://williamsconcepts.com/ci/codeignit...rence.html

and would like to integrate the Tank_Auth authentication module to my pages,
so to have a login/logout/register form in a $topbar template region i created.
Also to be able to control the display of certain regions depending on the log in status.

I have tried to do this on the Welcome page Controller, but i'm stuck.

getting an error "Unable to load the requested file: Array.php"

can anyone lead me in the right direction ? thanks. this is what i have so far

class Welcome extends CI_Controller {

function __construct()

    $this->load->helper(array('form', 'url'));

public function index()

      $this->template->add_css('css/style.css',$type = 'link');

    // if not logged in, show log on form in the topbar
    if (!$this->tank_auth->is_logged_in()) {



          $this->template->write_view('topbar', $data);

          $this->template->write_view('content', 'blank');

          $this->template->write_view('sidebar', 'templates/sidebar');              

    } else {
    //user is logged in, show log in info in top bar

         $data['user_id']    = $this->tank_auth->get_user_id();
         $data['username']   = $this->tank_auth->get_username();

                 $this->template->write_view('topbar', $data);

             // Write to $content
             $this->template->write_view('content', 'member_content');

             // Write to $sidebar
         $this->template->write_view('sidebar', 'templates/sidebar');              


  // Render the template


Hey I use the same library and this is how I integrated Tank Auth:

I edited the auth controller and replaced all

$this->load->view('viewNameHere', $data);


$this->template->write('title', 'Auth > Login / whatever');
$this->template->write_view('viewNameHere', $data);

So you should add all the static template regions in the constructor, or add them above the template->render() method. That should work, i did that and everything is working fine!

thanks a lot, i'll give it a try

Theme © iAndrew 2016 - Forum software by © MyBB