Welcome Guest, Not a member yet? Register   Sign In
Setting default variables in a controller
#2

[eluser]WeeJames[/eluser]
Code:
<?php
class User extends Controller {

var $controller;

function User()
{
  parent::Controller();
  
  $this->controller = 'user';
  $data['page_vars'] = $this->libadmin->page_vars($this->controller);  

  if ($this->session->userdata('logged_in') != TRUE){
   redirect('/admin/login/','location');
  }  
}

function activation()
  {  
  //access the global var with $this->controller anywhere you want in this class
  }

Try that.. i assume its just the string 'user' that you're trying to access.

You could also place the page_vars data into a variable in the same way.

Code:
<?php
class User extends Controller {

var $page_vars;

function User()
{
  parent::Controller();
  
  $this->page_vars = $this->libadmin->page_vars('user');  

  if ($this->session->userdata('logged_in') != TRUE){
   redirect('/admin/login/','location');
  }  
}

function activation()
  {  
  //now the page_vars data is available throughout this class via $this->page_vars and is always available after construction
  }

Read up on classes in php as this type of stuff isn't really CI related.


Messages In This Thread
Setting default variables in a controller - by El Forum - 07-15-2007, 12:15 AM
Setting default variables in a controller - by El Forum - 07-15-2007, 02:35 AM
Setting default variables in a controller - by El Forum - 07-15-2007, 02:41 AM
Setting default variables in a controller - by El Forum - 07-15-2007, 02:52 AM
Setting default variables in a controller - by El Forum - 07-15-2007, 02:59 AM
Setting default variables in a controller - by El Forum - 07-15-2007, 03:41 AM
Setting default variables in a controller - by El Forum - 07-15-2007, 03:43 AM
Setting default variables in a controller - by El Forum - 07-15-2007, 04:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB