Welcome Guest, Not a member yet? Register   Sign In
Community-Auth make this work in view?
#1

hi,

These codes work properly under controller.
Code:
    if( $this->require_min_level(9) )
       echo 'test';
    {   

So how to make it work under view page?

Thanks in advance.
Reply
#2

Class members declared public can be accessed everywhere.
Class members declared protected can be accessed only within the class itself and by inherited classes.
Class members declared as private may only be accessed by the class that defines the member.

You would need to extend the class and create your own method to call that protected method.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(03-28-2016, 06:08 PM)iridion2015 Wrote: hi,

These codes work properly under controller.
Code:
    if( $this->require_min_level(9) )
       echo 'test';
    {   

So how to make it work under view page?

Thanks in advance.

require_min_level, require_role, and the other authentication methods are always used in the controller. Take a look at Community Auth's Examples controller to see the proper usage. This behavior is not exclusive to Community Auth. You will find that most, if not all authentication systems will authenticate in the controller (unless they are applied in the routing).
Reply
#4

Does this code work properly ? Echo outside bracket and after if statement ?
NexoPOS 2.6.2 available on CodeCanyon.
Reply
#5

@skunkbad
Only in the controller only?
Is there a way to authenticate it in view page?
Reply
#6

(03-29-2016, 10:55 AM)iridion2015 Wrote: @skunkbad
Only in the controller only?
Is there a way to authenticate it in view page?

If there is a way, I'm not going to spend time figuring it out then posting a solution that goes against the basic principles of MVC. There would never be a good reason to use authentication functions n a view. I think if you spend time reading the Community Auth documentation, you'll find that Community Auth is very flexible and can do whatever you need. You might consider reading the CodeIgniter documentation as well.
Reply
#7

(This post was last modified: 03-29-2016, 11:57 PM by arma7x. Edit Reason: typo )

$data['level'] = $this->require_min_level(9):
$this->load->view('viewfile',$data['level']);
Now you have $level in your view.
Keep calm.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB