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

[eluser]Unknown[/eluser]
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

Code:
class Welcome extends CI_Controller {


function __construct()
{
    parent::__construct();

    $this->load->helper(array('form', 'url'));
    $this->load->library('form_validation');
    $this->load->library('security');
    $this->load->library('tank_auth');
    $this->lang->load('tank_auth');
}

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()) {


          $data['loginform']='login_form';

          //redirect('/auth/login/');


          $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
  $this->template->render();

}
}:question:
#2

[eluser]Haskabab[/eluser]
Hey I use the same library and this is how I integrated Tank Auth:

I edited the auth controller and replaced all

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

with

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

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!
#3

[eluser]Unknown[/eluser]
thanks a lot, i'll give it a try




Theme © iAndrew 2016 - Forum software by © MyBB