Welcome Guest, Not a member yet? Register   Sign In
How to access protected controller attributes from views
#1

[eluser]kimp[/eluser]
I have several views which show additional information if the user is an admin. These views include the following code:
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:
Code:
<?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!


Messages In This Thread
How to access protected controller attributes from views - by El Forum - 11-28-2010, 04:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB