• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[library] History

#11
[eluser]Peter Goodman[/eluser]
(I updated the post) Is there still the issue?

#12
[eluser]Dave S[/eluser]
Yes, this is what I have in my Login controller:

Code:
function Login() {
    
        parent::Controller();
        
        $this->history->exclude();

    }

Maybe I misunderstood what you were telling me to do. I'm pretty new to CI.

(I have the library auto-loading)

#13
[eluser]Peter Goodman[/eluser]
The way I have the history library now is somewhat different than how I explained it when I first made it with the hooks and whatnot. Here's a description how how I have it set up.

Code:
class MyCustomController extends Controller {
    public function __construct() {
        parent::Controller();
        $this->load->library('history');
    }
}

and then, to apply it to your example, here is a scenario:

Code:
class AuthController extends MyCustomController {
    public function Login() {
        $this->history->exclude();
    }
}

#14
[eluser]Dave S[/eluser]
Ok, I'm trying to get it figured out, please bear with me Smile

Do I not need the hooks anymore then?

I created a custom controller called MY_Controller and saved it as application/libraries/MY_Controller.php with contents exactly as your MyCustomController class.

Then, in my login controller I have:

Code:
class Login extends MY_Controller {
    
    function __construct() {
    
        parent::MY_Controller();
        
        $this->history->exclude();
}

But there is apparently a problem with parent::MY_Controller(); becuase this function doesn't exist. How do I extend this new class in my other constructors?

I can get around this by changing the name of the constructor (in MY_Controller.php) to MY_Controller() then I don't get that error, but it seems to break my modules_helper - I must be missing something.

I had the history thing working prior to all this, just not the exclude.

#15
[eluser]Peter Goodman[/eluser]
In your login controller you don't call parent::MY_Controller, call parent::__construct (php5 constructor). Also, here's a quick fix to my example controller that I forgot that negates the need for helpers.

Code:
class MyCustomController extends Controller {
    public function __construct() {
        parent::Controller();
        $this->load->library('history');
    }
    public function __destruct() {
        if($this->history)
            $this->history->push($this->uri->uri_string());
    }
}

#16
[eluser]erik.brannstrom[/eluser]
Great library! It works just fine for me now, after I realized I had to turn hooks on... Just one question, is there a reason for using a hook to load the library? At the moment I'm using the autoload in the config file and it's working like a charm.

#17
[eluser]Unknown[/eluser]
hi guys.. maybe it's something you all managed to fix in no time and didn't feel the need to point it out.. but it took me like 20 minutes to sort it out... Undecided there is a missing bracket on line 82...

#18
[eluser]Fero[/eluser]
Can someone just get me into what this library is for? Some lame explanation would be nice Smile

#19
[eluser]garymardell[/eluser]
The idea is that you can track where the user has visited on the site and use the data. For example if you wish to redirect the user back to the previous page. I mean say they went to a page but were not logged in and after login you want to redirect them to where they were you can. Or if you have 3 pages you need the user to view. So you can check that they have viewed the previous page so they can proceed.

#20
[eluser]Fero[/eluser]
Might be an offtopic, but isn't Google Analytics doing this?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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