• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to access protected controller attributes from views

I have several views which show additional information if the user is an admin. These views include the following code:
<?if ($this->session->userdata('userType') == 'Admin'): ?>

I have been trying to shorten this by setting a protected attribute in the controller, and testing this attribute (instead of the session userdata). The view code would then be something like:
<?if ($this->is_admin):?>

When I do this however I'm receiving the error message Undefined property: CI_Loader::$is_admin.

How can I make the controller's protected attributes available to the views (without explicitly passing them as part of the content array)? Or should I just make the attributes public?

Any assistance appreciated!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.