[library] History |
[eluser]Peter Goodman[/eluser]
This library provides an easy way to properly deal with history events. It only keeps track of unique history events and allows the programmer to exclude actions or controllers from within any controller. /libraries/History.php Code: <?php /hooks/history.php Code: <?php /config/hooks.php: Code: $hook['post_controller'] = array( Usage: Code: // exclude a page from history:
[eluser]Phil Sturgeon[/eluser]
Nice one! I hope some of your changes get included, alot of useful things have been posted here.
[eluser]Peter Goodman[/eluser]
Note to all PHP4 users: Making this php4 compatible is easy: remove all public/private/protected in front of function definitions. Remove all public/private/protected in front of class variable definitions (at the top of the class) and replace them with "var" Then, look for every "= get_instance()" and replace with "=& get_instance()"
[eluser]Phil Sturgeon[/eluser]
Remove the public/private in front of function declarations too :p
[eluser]ACSparks[/eluser]
What kind of overhead is associated with using this history class? Past pages are being stored in the session. Does this exist only in RAM or does each user have a session file on the server? If the session is a file on the server, wouldn't each page view correspond to a hard disk write? Thanks!
[eluser]Unknown[/eluser]
Hello, thanx for this library! but function pop in if(!$url) {... returns full url (http://domain.tld/ci/cont) else only something like "/cont" . When i use it in redirect($this->history->pop()); it jumps to http://domain.tld/ci/http://domain.tld/ci/cont (404) I solved it by modifiing functions pop & end to: Code: public function pop() { so HTTP_REFERER redirecting works well but i want to use $url = array_shift($this->history); not this my question is why it cant use address from history and must use HTTP_REFERER. I dont know when it occurs, maybe something wrong with redirect($this->history->pop()); (btw codeigniter beginner..) EDIT: solved: Simplelogin deleted sessions data on every login/logout, so i lost my url history..
[eluser]Dave S[/eluser]
This library is great! It's exactly what I was looking for. I do have one question though, if I want to exclude a page from being added to the history, where do I put this line: Code: $this->history->exclude(); I tried placing it in the constructor of the controller, as well as in the index function, but it is still being added. Thanks again!
[eluser]Peter Goodman[/eluser]
You put in either the method itself (to exclude a method) or the controller's constructor (to exclude an entire controller). The easiest way to have it all working is to make your own controller extending CI's default one and in that constructor load up the history library (as well as calling the parent constructor). If this doesn't work, please reply here.
[eluser]Dave S[/eluser]
Hmm... I did try it in the constructor but somehow it's still getting added. |
Welcome Guest, Not a member yet? Register Sign In |